consensus-decentralization icon indicating copy to clipboard operation
consensus-decentralization copied to clipboard

Make tests self-contained

Open LadyChristina opened this issue 2 years ago • 3 comments

Currently some tests share the same setup, e.g. read the same input files, which can potentially cause problems and make maintenance harder. It would be good for every test to be responsible for its input and output. It's probably better to also delete all files associated with a test after it's done.

LadyChristina avatar Mar 03 '23 14:03 LadyChristina

One issue that arises by not deleting test output files is that in some cases (e.g. mapping) we only go ahead with the process if the output file doesn't already exist. This means that if we change the relevant code between two test runs then the updated code won't be tested because the test output file will already exist.

LadyChristina avatar May 02 '23 09:05 LadyChristina

Another issue is that in the mapping tests we also perform parsing, so the test will fail if there is something wrong with the parser, even if the mapping is fine. I think it's better for the mapping tests to receive the parser output as input directly so that they are independent of the parser's code.

LadyChristina avatar May 02 '23 09:05 LadyChristina

Some useful guidelines for writing Python tests: https://docs.python-guide.org/writing/tests/

LadyChristina avatar May 02 '23 10:05 LadyChristina