To run the tests locally you need to have pytest installed. It is already part of the requirements_developers.txt file. You can run the tests via:
The tests which are executed in TRD are as follows:
acceptance tests (WIP)
non functional tests. (WIP)
formal verification (WIP)
Unit tests test only one specific function or method of a class. The smaller the function and the more specialized it is the better the unit test.
Regression tests are tests which document fixed bugs. To implement a regression test you need to do the following:
Have a bug in trd (see bug label in issues)
Reproduce the bug in a test under the regression/ directory.
Assert the behaviour which you would like this bug to have.
Fix the bug and make the test pass.
Integration tests test the behaviour of trd. Meaning it tests the interaction between multiple functions or classes.
Smoke tests test if trd starts, runs and ends under different cirumstances.
Acceptance test (WIP)¶
Acceptance tests test the functionality which users are expecting to work. E.g. the correct and reliable distribution of rewards.
Non functional tests (WIP)¶
Non functional tests test the performance, load time, transaction speed etc. of trd.
Checking the FSM model systematically with exhaustive exploration. This consists of exploring all states and transitions in the model (source).
Name the test file according to the feature/function you want to test and the “test_” prefix (e.g. test_sample.py). Only use functions to write the actual tests for simplicity. If applicable make use of pytest’s fixtures to avoid code duplication. Check the pytest documentation and tutorials for more info on how to write pytest tests.
Visual Studio Code Test Execution (optional)¶
If you are using Visual Studio Code, you want to use it with the extensions installed in the previous section and check them here:
Then click on the test icon tab
Click on Configure Python Tests
Select the test folder
Now you can see all the test which are runnable
Now run all tests