Blame tests/WRITING_TESTS.md

Packit Service fb147c
## Writing new tests
Packit Service fb147c
Packit Service fb147c
The test suite is intended to run a binary and compare its standard output,
Packit Service fb147c
standard error and return value against provided values. This is implemented
Packit Service fb147c
using Python's `unittest` module and thus all test files are Python files.
Packit Service fb147c
Packit Service fb147c
The simplest test has the following structure:
Packit Service fb147c
``` python
Packit Service fb147c
# -*- coding: utf-8 -*-
Packit Service fb147c
Packit Service fb147c
import system_tests
Packit Service fb147c
Packit Service fb147c
Packit Service fb147c
class GoodTestName(metaclass=system_tests.CaseMeta):
Packit Service fb147c
Packit Service fb147c
    filename = "$data_path/test_file"
Packit Service fb147c
    commands = ["$exiv2 $filename", "$exiv2 $filename" + '_2']
Packit Service fb147c
    stdout = [""] * 2
Packit Service fb147c
    stderr = ["""$exiv2_exception_msg $filename:
Packit Service fb147c
$kerFailedToReadImageData
Packit Service fb147c
"""] * 2
Packit Service fb147c
    retval = [1] * 2
Packit Service fb147c
```
Packit Service fb147c
Packit Service fb147c
The test suite will run the provided commands in `commands` and compare them to
Packit Service fb147c
the output in `stdout` and `stderr` and it will compare the return values.
Packit Service fb147c
Packit Service fb147c
The strings after a `$` are variables either defined in this test's class or are
Packit Service fb147c
taken from the suite's configuration file (see `doc.md` for a complete
Packit Service fb147c
explanation).
Packit Service fb147c
Packit Service fb147c
When creating new tests, follow roughly these steps:
Packit Service fb147c
Packit Service fb147c
1. Choose an appropriate subdirectory where the test belongs. If none fits
Packit Service fb147c
   create a new one and put an empty `__init__.py` file there.
Packit Service fb147c
Packit Service fb147c
2. Create a new file with a name matching `test_*.py`. Copy the class definition
Packit Service fb147c
   from the above example and choose an appropriate class name.
Packit Service fb147c
Packit Service fb147c
3. Run the test suite via `python3 runner.py` and ensure that your test case is
Packit Service fb147c
   actually run! Either run the suite with the `-v` option which will output all
Packit Service fb147c
   test cases that were run or simply add an error and check if errors occur.