I was trying to do the beginner level testing of ROS 2 packages by following the official ROS 2 Documentation, Writing Basic Tests with C++ with GTest, and when I tried to build the package and run the dummy test I am getting the following errors,
details about the package I created : package name : test_package
command I tried to run
colcon build --packages-select test_package
The package got successfully build. and then when I tried the next command given bellow I am getting errors
COMMAND : colcon test --packages-select test_package --ctest-args tests
RESULT
jishnu@Legion:~/testros/workspace$ colcon test --packages-select test_package --ctest-args tests
Starting >>> test_package
--- stderr: test_package
Errors while running CTest
Output from these tests are in: /home/jishnu/testros/workspace/build/test_package/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
---
Finished <<< test_package [1.41s] [ with test failures ]
Summary: 1 package finished [1.59s]
1 package had stderr output: test_package
1 package had test failures: test_package
COMMAND : colcon test --packages-select test_package --event-handlers console_direct+
RESULT
jishnu@Legion:~/testros/workspace$ colcon test --packages-select test_package --event-handlers console_direct+
Starting >>> test_package
UpdateCTestConfiguration from :/home/jishnu/testros/workspace/build/test_package/CTestConfiguration.ini
Parse Config file:/home/jishnu/testros/workspace/build/test_package/CTestConfiguration.ini
Site: Legion
Build name: (empty)
Add coverage exclude regular expressions.
Create new tag: 20230425-1728 - Experimental
UpdateCTestConfiguration from :/home/jishnu/testros/workspace/build/test_package/CTestConfiguration.ini
Parse Config file:/home/jishnu/testros/workspace/build/test_package/CTestConfiguration.ini
Test project /home/jishnu/testros/workspace/build/test_package
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 1
Start 1: test_package_tutorial_test
1: Test command: /usr/bin/python3.10 "-u" "/opt/ros/humble/share/ament_cmake_test/cmake/run_test.py" "/home/jishnu/testros/workspace/build/test_package/test_results/test_package/test_package_tutorial_test.gtest.xml" "--package-name" "test_package" "--output-file" "/home/jishnu/testros/workspace/build/test_package/ament_cmake_gtest/test_package_tutorial_test.txt" "--command" "/home/jishnu/testros/workspace/build/test_package/test_package_tutorial_test" "--gtest_output=xml:/home/jishnu/testros/workspace/build/test_package/test_results/test_package/test_package_tutorial_test.gtest.xml"
1: Test timeout computed to be: 60
1: -- run_test.py: invoking following command in '/home/jishnu/testros/workspace/build/test_package':
1: - /home/jishnu/testros/workspace/build/test_package/test_package_tutorial_test --gtest_output=xml:/home/jishnu/testros/workspace/build/test_package/test_results/test_package/test_package_tutorial_test.gtest.xml
1: [==========] Running 1 test from 1 test suite.
1: [----------] Global test environment set-up.
1: [----------] 1 test from package_name
1: [ RUN ] package_name.a_first_test
1: [ OK ] package_name.a_first_test (0 ms)
1: [----------] 1 test from package_name (0 ms total)
1:
1: [----------] Global test environment tear-down
1: [==========] 1 test from 1 test suite ran. (1 ms total)
1: [ PASSED ] 1 test.
1: -- run_test.py: return code 0
1: -- run_test.py: inject classname prefix into gtest result file '/home/jishnu/testros/workspace/build/test_package/test_results/test_package/test_package_tutorial_test.gtest.xml'
1: -- run_test.py: verify result file '/home/jishnu/testros/workspace/build/test_package/test_results/test_package/test_package_tutorial_test.gtest.xml'
1/5 Test #1: test_package_tutorial_test ....... Passed 0.09 sec
test 2
Start 2: cppcheck
2: Test command: /usr/bin/python3.10 "-u" "/opt/ros/humble/share/ament_cmake_test/cmake/run_test.py" "/home/jishnu/testros/workspace/build/test_package/test_results/test_package/cppcheck.xunit.xml" "--package-name" "test_package" "--output-file" "/home/jishnu/testros/workspace/build/test_package/ament_cppcheck/cppcheck.txt" "--command" "/opt/ros/humble/bin/ament_cppcheck" "--xunit-file" "/home/jishnu/testros/workspace/build/test_package/test_results/test_package/cppcheck.xunit.xml" "--include_dirs" "/home/jishnu/testros/workspace/test_package/include"
2: Test timeout computed to be: 300
2: -- run_test.py: invoking following command in '/home/jishnu/testros/workspace/test_package':
2: - /opt/ros/humble/bin/ament_cppcheck --xunit-file /home/jishnu/testros/workspace/build/test_package/test_results/test_package/cppcheck.xunit.xml --include_dirs /home/jishnu/testros/workspace/test_package/include
2: cppcheck 2.7 has known performance issues and therefore will not be used, set the AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS environment variable to override this.
2: -- run_test.py: return code 0
2: -- run_test.py: verify result file '/home/jishnu/testros/workspace/build/test_package/test_results/test_package/cppcheck.xunit.xml'
2/5 Test #2: cppcheck ......................... Passed 0.23 sec
test 3
Start 3: lint_cmake
3: Test command: /usr/bin/python3.10 "-u" "/opt/ros/humble/share/ament_cmake_test/cmake/run_test.py" "/home/jishnu/testros/workspace/build/test_package/test_results/test_package/lint_cmake.xunit.xml" "--package-name" "test_package" "--output-file" "/home/jishnu/testros/workspace/build/test_package/ament_lint_cmake/lint_cmake.txt" "--command" "/opt/ros/humble/bin/ament_lint_cmake" "--xunit-file" "/home/jishnu/testros/workspace/build/test_package/test_results/test_package/lint_cmake.xunit.xml"
3: Test timeout computed to be: 60
3: -- run_test.py: invoking following command in '/home/jishnu/testros/workspace/test_package':
3: - /opt/ros/humble/bin/ament_lint_cmake --xunit-file /home/jishnu/testros/workspace/build/test_package/test_results/test_package/lint_cmake.xunit.xml
3:
3: No problems found
3: -- run_test.py: return code 0
3: -- run_test.py: verify result file '/home/jishnu/testros/workspace/build/test_package/test_results/test_package/lint_cmake.xunit.xml'
3/5 Test #3: lint_cmake ....................... Passed 0.20 sec
test 4
Start 4: uncrustify
4: Test command: /usr/bin/python3.10 "-u" "/opt/ros/humble/share/ament_cmake_test/cmake/run_test.py" "/home/jishnu/testros/workspace/build/test_package/test_results/test_package/uncrustify.xunit.xml" "--package-name" "test_package" "--output-file" "/home/jishnu/testros/workspace/build/test_package/ament_uncrustify/uncrustify.txt" "--command" "/opt/ros/humble/bin/ament_uncrustify" "--xunit-file" "/home/jishnu/testros/workspace/build/test_package/test_results/test_package/uncrustify.xunit.xml"
4: Test timeout computed to be: 60
4: -- run_test.py: invoking following command in '/home/jishnu/testros/workspace/test_package':
4: - /opt/ros/humble/bin/ament_uncrustify --xunit-file /home/jishnu/testros/workspace/build/test_package/test_results/test_package/uncrustify.xunit.xml
4: Code style divergence in file 'src/SystemTests.cpp':
4:
4: --- src/SystemTests.cpp
4: +++ src/SystemTests.cpp.uncrustify
4: @@ -5 +5 @@
4: - ASSERT_EQ(4, 2 + 2);
4: + ASSERT_EQ(4, 2 + 2);
4: @@ -8 +8 @@
4: -int main(int argc, char **argv)
4: +int main(int argc, char ** argv)
4: @@ -10,3 +10,3 @@
4: - testing::InitGoogleTest(&argc, argv);
4: - return RUN_ALL_TESTS();
4: -}
4: + testing::InitGoogleTest(&argc, argv);
4: + return RUN_ALL_TESTS();
4: +}
4:
4: 1 files with code style divergence
4: -- run_test.py: return code 1
4: -- run_test.py: verify result file '/home/jishnu/testros/workspace/build/test_package/test_results/test_package/uncrustify.xunit.xml'
4/5 Test #4: uncrustify .......................***Failed 0.27 sec
test 5
Start 5: xmllint
5: Test command: /usr/bin/python3.10 "-u" "/opt/ros/humble/share/ament_cmake_test/cmake/run_test.py" "/home/jishnu/testros/workspace/build/test_package/test_results/test_package/xmllint.xunit.xml" "--package-name" "test_package" "--output-file" "/home/jishnu/testros/workspace/build/test_package/ament_xmllint/xmllint.txt" "--command" "/opt/ros/humble/bin/ament_xmllint" "--xunit-file" "/home/jishnu/testros/workspace/build/test_package/test_results/test_package/xmllint.xunit.xml"
5: Test timeout computed to be: 60
5: -- run_test.py: invoking following command in '/home/jishnu/testros/workspace/test_package':
5: - /opt/ros/humble/bin/ament_xmllint --xunit-file /home/jishnu/testros/workspace/build/test_package/test_results/test_package/xmllint.xunit.xml
5: File 'package.xml' is valid
5:
5: No problems found
5: -- run_test.py: return code 0
5: -- run_test.py: verify result file '/home/jishnu/testros/workspace/build/test_package/test_results/test_package/xmllint.xunit.xml'
5/5 Test #5: xmllint .......................... Passed 1.60 sec
80% tests passed, 1 tests failed out of 5
Label Time Summary:
cppcheck = 0.23 sec*proc (1 test)
gtest = 0.09 sec*proc (1 test)
lint_cmake = 0.20 sec*proc (1 test)
linter = 2.30 sec*proc (4 tests)
uncrustify = 0.27 sec*proc (1 test)
xmllint = 1.60 sec*proc (1 test)
Total Test time (real) = 2.42 sec
The following tests FAILED:
4 - uncrustify (Failed)
Errors while running CTest
Output from these tests are in: /home/jishnu/testros/workspace/build/test_package/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
--- stderr: test_package
Errors while running CTest
Output from these tests are in: /home/jishnu/testros/workspace/build/test_package/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
---
Finished <<< test_package [5.11s] [ with test failures ]
Summary: 1 package finished [5.29s]
1 package had stderr output: test_package
1 package had test failures: test_package
Is there a way to by pass this system generated test and only conduct the custom tests provided in the test file?
./home/jishnu/testros/workspace/build/test_package/test_package_tutorial_test
, it's listed in your result output above in step 1. The additional--gtest_output
flag specifies to generate a XML report (see google.github.io/googletest/…) $\endgroup$