Tests
There are python unit tests in this directory. They test the servers functionality by sending requests to the server and checking the response.
The server software has to run on the device for the unit tests to work. The tests will fail if the server is not running.
Important note
Write a test case in the following cases:
You added a new feature.
You fixed a bug. Create a test case which tests the behavior which caused the bug.
Run the test cases always before pushing new code to the repository. Update the test cases as needed!
How to run the tests
Before running the unit tests the test suite needs to be setup correctly. This
is done by copying the settings_local.py.example
file to
settings_local.py
and editing the file to match your setup.
cp settings_local.py.example settings_local.py
There set the correct port and IP address of the device. Make sure the device is running the server and nothing is connected to the ADC (this is subject to change)!
Then you can run the tests from within the test
directory with the
following command:
python3 -m unittest discover
The actual tests are within the files starting with test_
.
If you want to run a specific test file you can do so with the following command:
python3 -m unittest <test_file_name>
If you want to run a specific test case within a test file you can do so with the following command:
python3 -m unittest <test_file_name>.TestSequence.<test_case_name>
<test_case_name> is the name of the test case method within the test file. TestSequence is the name of the test class within the test file. It should be always TestSequence.
Adding a new test case
If your test case fits within an existing test file, add it there. Otherwise
create a new test file. If you create a new test file, make sure it start with
test_
and xx
where xx
is the next number after the last test file.
The numbers after test_
as well as the numbers within the test case names
are used to run the test cases in a specific order. The python unit test system
runs all tests in alphabetical order. This is why the numbers are needed.