diff --git a/docs/how-to/write-tests.md b/docs/how-to/write-tests.md new file mode 100644 index 0000000000..ad4316e4fe --- /dev/null +++ b/docs/how-to/write-tests.md @@ -0,0 +1,8 @@ +# Writing Tests in This Python Project + +Testing is essential to maintain the integrity and reliability of the codebase. Follow the guidelines below to write tests for this project effectively. + +## Test Organization + +- **Unit Tests**: Place unit tests for individual components in the `tests` directory, but take care to mirror the file structure of the `src` folder with the corresponding code files. Use the `test_*.py` naming convention for test files. +- **System Tests**: Tests that interact with DLS infrastructure, network, and filesystem should be placed in the top-level `systems_test` folder. This separation ensures that these tests are easily identifiable and can be run independently from unit tests. diff --git a/pyproject.toml b/pyproject.toml index f1f8e42e63..b65b66a9a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -115,7 +115,7 @@ filterwarnings = [ "ignore::DeprecationWarning:wheel", ] # Doctest python code in docs, python code in src docstrings, test functions in tests -testpaths = "docs src tests" +testpaths = "docs src tests system_tests" [tool.coverage.report] exclude_also = [ @@ -176,3 +176,4 @@ lint.select = [ # See https://github.com/DiamondLightSource/python-copier-template/issues/154 # Remove this line to forbid private member access in tests "tests/**/*" = ["SLF001"] +"system_tests/**/*" = ["SLF001"] diff --git a/tests/devices/system_tests/__init__.py b/system_tests/__init__.py similarity index 100% rename from tests/devices/system_tests/__init__.py rename to system_tests/__init__.py diff --git a/tests/devices/system_tests/test_aperturescatterguard_system.py b/system_tests/test_aperturescatterguard_system.py similarity index 100% rename from tests/devices/system_tests/test_aperturescatterguard_system.py rename to system_tests/test_aperturescatterguard_system.py diff --git a/tests/devices/system_tests/test_eiger_system.py b/system_tests/test_eiger_system.py similarity index 100% rename from tests/devices/system_tests/test_eiger_system.py rename to system_tests/test_eiger_system.py diff --git a/tests/devices/system_tests/test_gridscan_system.py b/system_tests/test_gridscan_system.py similarity index 100% rename from tests/devices/system_tests/test_gridscan_system.py rename to system_tests/test_gridscan_system.py diff --git a/tests/devices/system_tests/test_oav_system.py b/system_tests/test_oav_system.py similarity index 100% rename from tests/devices/system_tests/test_oav_system.py rename to system_tests/test_oav_system.py diff --git a/tests/devices/system_tests/test_oav_to_redis_system.py b/system_tests/test_oav_to_redis_system.py similarity index 100% rename from tests/devices/system_tests/test_oav_to_redis_system.py rename to system_tests/test_oav_to_redis_system.py diff --git a/tests/devices/system_tests/test_slit_gaps_system.py b/system_tests/test_slit_gaps_system.py similarity index 100% rename from tests/devices/system_tests/test_slit_gaps_system.py rename to system_tests/test_slit_gaps_system.py diff --git a/tests/devices/system_tests/test_smargon_system.py b/system_tests/test_smargon_system.py similarity index 100% rename from tests/devices/system_tests/test_smargon_system.py rename to system_tests/test_smargon_system.py diff --git a/tests/devices/system_tests/test_synchrotron_system.py b/system_tests/test_synchrotron_system.py similarity index 100% rename from tests/devices/system_tests/test_synchrotron_system.py rename to system_tests/test_synchrotron_system.py diff --git a/tests/devices/system_tests/test_undulator_system.py b/system_tests/test_undulator_system.py similarity index 100% rename from tests/devices/system_tests/test_undulator_system.py rename to system_tests/test_undulator_system.py diff --git a/tests/devices/system_tests/test_zebra_system.py b/system_tests/test_zebra_system.py similarity index 100% rename from tests/devices/system_tests/test_zebra_system.py rename to system_tests/test_zebra_system.py diff --git a/tests/devices/system_tests/test_zocalo_results.py b/system_tests/test_zocalo_results.py similarity index 100% rename from tests/devices/system_tests/test_zocalo_results.py rename to system_tests/test_zocalo_results.py