0

Here is my folder structure:

src/
src/package1
src/package1/package1
src/package1/package1/__init__.py
src/package1/package1/class_package1.py
src/package1/package1/test_package1.py
src/package2
src/package2/package2
src/package1/package2/__init__.py
src/package2/package2/class_package1.py
src/package2/package2/test_package1.py

This is a ROS2 packages structure, I can't modify it.

  • Running python -m unittest from src/package1/package1 runs all package1 tests
  • Running python -m unittest from src/package2/package2 runs all package2 tests
  • Running python -m unittest discover package1/package1 from src runs all package1 tests
  • Running python -m unittest discover package2/package2 from src runs all package2 tests

However, is there a way to run all package1 AND package2 tests from src folder?

I suppose moving all tests to a new test package could make this work easily but I'd like to avoid that. I like tests to remain close to code itself.

5
  • Does python -m unittest discover (without package specification) work? Commented Dec 4, 2023 at 15:54
  • @YevhenKuzmovych: No, it reports no test found Commented Dec 5, 2023 at 7:59
  • @jpo38 This post could help you? Commented Dec 11, 2023 at 14:53
  • @User051209: Not exactly what I'm looking for because I want to do this from a command line but thanks. Commented Dec 12, 2023 at 8:31
  • @jpo38 You can define a file runner_test.py (as explained in the post) in the folder src and execute python runner_test.py by command line. I don't know if it is possible avoid writing code to solve your problem. Commented Dec 12, 2023 at 9:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.