Skip to main content

Functional testing tool

Project description

Refery

Refery is a functional test tool written in Python.

Install

pip install -U refery

Usage

usage: refery [-h] -f <path> [--verbosity <verbose|silent|normal>] [--junit-file <path>]

options:
  -h, --help            show this help message and exit
  -f <path>, --test-file <path>
                        Path to the YAML test file.
  --verbosity <verbose|silent|normal>
                        Output's verbosity, defaults to 'normal'.
  --junit-file <path>   Optional path to a JUnit XML file in which to write the output

As you can see, refery's only mandatory argument is a path to the YAML file describing the collection of test suites to be run.

Writing tests

Individual tests are represented by test cases and a test suite is a collection of test cases.

Test suites

Test suites are a given as a YAML sequence which is the value associated to the YAML mapping key testsuites.

Each test suite is a YAML mapping which accepts the following fields:

Field Description Optional
name Name of the test suite.
tests YAML sequence containing the test cases.
setup Command to execute before each test case.
teardown Command to execute after each test case.
fatal Indicates if a failure in a test case means an abortion of the runner. Defaults to false.

Test cases

Each test case is a YAML mapping accepting the following fields:

Name Description Optional
name Name of the test case.
binary Path to the tested executable.
args YAML sequence containing the arguments passed to the executable.
ref Path to an executable with the desired behaviour.
stdin String passed as standard input.
stdout Expected standard output.
stderr Expected standard error.
exit_code Expected exit code.
skipped Boolean indicating whether the test case shall be ignored.
timeout Timeout in seconds, after which the test case is stopped marked as failed.
stdout_mode/stderr_mode The testing mode of the two output streams.
Can be of two kinds:
  • strict: The actual value shall be the same as the expected value.
  • exists: If the expected value is not empty, the actual value shall not be empty and reciprocally.
Both stdout_mode and stderr_mode default to strict.

If the ref is specified, it is used to test the standard output, standard error and exit code. If any of these fields is specified, they take precedence over ref.

For example, take the following test case:

hello:
  ref: bin/hello.sh
  exit_code: 0

The stdout and stderr are tested according to bin/hello.sh but the exit code must be equal to 0, no matter what is actually returned by bin/hello.sh.

Default value

An optional YAML mapping can be used to specify default values for all test cases. It must be passed as a value to the default key and can contain all fields accepted by test cases. For each test case, if a field is already defined, the one defined in the test case takes precedence.

Here is an example of a valid input file :

default:
  binary: my_hello.sh
  ref: bin/hello
  stderr_mode: exists

testsuites:
  - name: hello
    fatal: true
    tests:
      - name: simple_hello
      - name: hello_with_name
        timeout: 1
        args:
          - John Doe
  - name: goodbye
    tests:
      - name: bye
        ref: bin/goodbye
        timeout: 1
        args:
          - --bye
          - John Doe

This defines two test suites, the first containing two test cases and the second only one.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

refery-2.1.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

refery-2.1.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file refery-2.1.0.tar.gz.

File metadata

  • Download URL: refery-2.1.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.0 Darwin/23.0.0

File hashes

Hashes for refery-2.1.0.tar.gz
Algorithm Hash digest
SHA256 daafdc841e2293db12dcf11bcc38605fbc347a774ee3af1cb23e60cd3a75f6a2
MD5 ad4aca5b63f543468f5f45de1079a1fa
BLAKE2b-256 26a1b810b81f9bd7be84d9c1db15da90f4c625dfb207c78e486b1899d648782f

See more details on using hashes here.

File details

Details for the file refery-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: refery-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.0 Darwin/23.0.0

File hashes

Hashes for refery-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a25e2ebe6fe2040173dd0271e896f7263d8028bebd9770604e59d43f8677d94e
MD5 dfe76a70e5094717797caae25e2438d8
BLAKE2b-256 d46d547da582fd1cf20643d1ba85b1bb0c5c240bf8bd6ee86928375b7417d38f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page