Sorts Unit Tests | Testing Framework & Procedures | Fluid Attacks Help

Sorts unit tests

This section provides a comprehensive overview of the unit testing procedures implemented for Sorts. It highlights the significance of unit testing in ensuring the reliability and functionality of individual components within the codebase.

We exclusively employ unit testing to validate the behavior and functionality of each isolated unit of code. These tests meticulously scrutinize the logic and functionality of components such as sorting algorithms and intricate edge cases.

Our unit tests are seamlessly integrated into our CI/CD pipeline, running automatically every time a developer pushes changes to our repository. They can also be executed locally. To run unit tests in Sorts locally, navigate to the universe repository and execute the following command:

sorts-core-test

To develop a unit test, add it to sorts/core/tests:

def test_check_url_components() -> None:
  #Test implementation goes here

When writing unit tests, adhere to these steps to ensure that the tests are repeatable, fast, independent, and descriptive:
  1. Test file: We store our tests using the same structure as our repository. Inside universe/sorts/core/tests/ you can find our unit tests. Look for the test_module_to_test.py file or add it if missing.
  2. Write the test: Begin writing the test once the file is ready. Consider the purpose of the function, method, or class being tested, and anticipate its behavior with different inputs. Identify extreme scenarios to include in the test cases, which are crucial for writing comprehensive assertions.

  3. With this setup, you can run the test using the following command:

    sorts-core-test

  4. Assertions: Validate the expected behavior using assertions. Verify results, the number of functions, etc.
Idea
Tip
Have an idea to simplify our architecture or noticed docs that could use some love? Don't hesitate to open an issue or submit improvements.