Skip to content

Commit

Permalink
tutorial/integration_testing: Leave changes to CLI tutorial for other…
Browse files Browse the repository at this point in the history
… PR.

Signed-off-by: Arne Baeyens <mail@arnebaeyens.com>
  • Loading branch information
Arne Baeyens committed Dec 9, 2024
1 parent b9278e7 commit 620dbab
Showing 1 changed file with 2 additions and 39 deletions.
41 changes: 2 additions & 39 deletions source/Tutorials/Intermediate/Testing/CLI.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,21 @@ To compile and run the tests, simply run the `test <https://colcon.readthedocs.i
:ref:`Sourcing the workspace <colcon-tutorial-source-the-environment>` before testing should not be necessary.
``colcon test`` makes sure that the tests run with the right environment, have access to their dependencies, etc.

The above command suppresses the test output and exposes little about which tests succeed and which fail.
Therefore while developing tests the ``--event-handlers`` option is useful to print all test output while the tests are running:

.. code-block:: console
colcon test --event-handlers console_direct+
Examine Test Results
^^^^^^^^^^^^^^^^^^^^

To see the results, simply run the `test-result <https://colcon.readthedocs.io/en/released/reference/verb/test-result.html>`__ verb from ``colcon``:
To see the results, simply run the `test-result <https://colcon.readthedocs.io/en/released/reference/verb/test-result.html>`__ verb from ``colcon``.

.. code-block:: console
$ colcon test-result --all
build/app/Testing/20241013-0810/Test.xml: 1 tests, 0 errors, 1 failure, 0 skipped
build/app/test_results/app/test_test_myapp.py.xunit.xml: 3 tests, 0 errors, 1 failure, 0 skipped
Summary: 4 tests, 0 errors, 2 failures, 0 skipped
In the example above, the command lists two files:

* a ctest-formatted XML file (a result of the ``CMakeLists.txt``)
* an XUnit-formatted XML file, which is suitable for automatic report generation in automated testing in CI/CD pipelines.
colcon test-result --all
To see the exact test cases which fail, use the ``--verbose`` flag:

.. code-block:: console
colcon test-result --all --verbose
A suitable non-ROS specific tool to visualize them all together is the
`NodeJS package Xunit Viewer <https://github.com/lukejpreston/xunit-viewer>`_.
It converts the XUnit files to HTML or straight into the terminal.
For example, command and response (without highlighting):

.. code-block:: console
$ xunit-viewer -r build -c
app.test_integration.launch_tests
✗ test_publishes_pose time=0.52
- Traceback (most recent call last):
File "/home/user/ros_workspace/src/app/test/test_myapp.py", line 67, in test_publishes_pose
assert len(msgs_rx) > 100
^^^^^^^^^^^^^^^^^^
AssertionError
✓ test_exit_codes time=0.0
✓ test_logs_spawning time=0.197
1 failure, 2 passed
Written to: /home/user/ros_workspace/index.html
Debugging tests with GDB
^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down

0 comments on commit 620dbab

Please sign in to comment.