Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 4

Answer by Dirk Thomas for Hi all,I am writing some tests for my ROS2 Python package. I want to specify different levels of tests (unittest, integrationtests, system tests, ...) and run them with colcon test . I have the different tests in subfolders in the test directory:my_pkg ├── launch │   └── example.launch.py ├── my_pkg │   ├── __init__.py │   ├── my_node.py │   ├── publisher.py │   ├── subscriber.py │   └── transformer.py ├── package.xml ├── README.md ├── resource │   └── my_pkg ├── setup.cfg ├── setup.py └── test ├── integrationtest │   └── test_integration.py └── unittest ├── test_pytest.py └── test_unittest.py Colcon detects all tests, what is great. But sometimes I only want run e.g. the tests in the directory unittests. That woult be useful, because some of my integration or system tests needs a long time!Are there any possibilities to run a specific subfolder of the test directory with colcon test? Have colcon some command line arguments for this? Or is there another way to go?

Next: Comment by shonigmann for Hi all,I am writing some tests for my ROS2 Python package. I want to specify different levels of tests (unittest, integrationtests, system tests, ...) and run them with colcon test . I have the different tests in subfolders in the test directory:my_pkg ├── launch │   └── example.launch.py ├── my_pkg │   ├── __init__.py │   ├── my_node.py │   ├── publisher.py │   ├── subscriber.py │   └── transformer.py ├── package.xml ├── README.md ├── resource │   └── my_pkg ├── setup.cfg ├── setup.py └── test ├── integrationtest │   └── test_integration.py └── unittest ├── test_pytest.py └── test_unittest.py Colcon detects all tests, what is great. But sometimes I only want run e.g. the tests in the directory unittests. That woult be useful, because some of my integration or system tests needs a long time!Are there any possibilities to run a specific subfolder of the test directory with colcon test? Have colcon some command line arguments for this? Or is there another way to go?
$
0
0
`colcon` simply invokes the unit testing framework used by each package when `colcon test` is being called. If that testing framework has command line options to select/deselect specific tests you can easily provide them through `colcon`. E.g. for `pytest` you can use `colcon test --pytest-args ...` and use any of the sophisticated options like: * markers with `-k` (https://docs.pytest.org/en/stable/example/markers.html#marking-test-functions-and-selecting-them-for-a-run) or * regular expression with `-m` (https://docs.pytest.org/en/stable/example/markers.html#using-k-expr-to-select-tests-based-on-their-name).

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>