Blame tests/writing_tests.md

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