Skims unit tests
Unit tests in Skims focus on verifying the functionality of individual units or components of our software.
Our unit test run in our CI/CD pipeline,
every time a developer pushes changes to our repository. They also can be run
locally. To run locally the unit tests in Skims,
enter the universe
repository and run:
To develop a unit test,
add it to the folder skims/test/unit
and include the following configuration:
When writing unit tests, you can follow these steps to ensure that the test is repeatable, fast, independent, and descriptive:
-
Test file: We store our tests using the same structure as our repository. Inside
universe/skims/test/unit/
you can find our unit tests. Look for thetest_module_to_test.py
file or add it if missing. -
Write the test: Add the
skims_test_group
decorator to your test function. This decorator categorizes your test under a specific group name, ensuring consistency across all unit tests in Skims. To add this decorator, simply include it in your test function with the desired group name. Then, ensure that the same group name (unittesting) is added toskims/test/test_groups.json
. With this setup, yo can run the test using the following command: -
Assertions: Test the expected behavior. We use assertions to validate results, the number of function or mock calls, and the arguments used in mocks.
Once your test is ready, format your code by running this command within the
universe
repository:
And use a linter: