Is there a way to report the results in a JUnit XML format with CTest?
I have found the the --output-junit
comand-line switch but running ctest --output-junit testRes.xml
does not create output file...
ctest --output-junit testRes.xml doas not create output file...
This is relatively new feature, You just need to update Your CMake / CTest to v.3.21.4 or higher (ref. https://cmake.org/cmake/help/v3.21/manual/ctest.1.html)
ctest --output-junit build/ctest-results.xml --test-dir build
will create a file ./build/build/ctest-results.xml
, that is, the output file specified with the option --output-junit
is relative to the directory specified with --test-dir
, not relative to the current directory. –
Alida ctest
very helpfully does not give any kind of unknown argument
error - it just ignores unknown arguments. That's the kind of shoddy engineering that costs people (i.e. me) hours of their lives. :-/ –
Knowable Same issue. I don't examine it deeply. But I guess there is convenient workaround: ask CMake to call test executable with native option aimed to produce JUnit report by itself.
This approach allows you to get as detailed JUnit report as possible. Such report will contain individual log records of each test case being inside called executable file, not whole executable at once. I proceed from the assumption that in general case CMake cann't parse stdout of every test framework at any verbosity level to collect anought data to produce pretty JUnit report.
Moving on to the example, let's say we are dealing with a unit test based on Boost.Test
. Then just add it to a CMake project by the following way
add_test(
NAME ${test_name}
COMMAND ${boost_test_executable_file} --logger=JUNIT,message,${path_to_junit_log}
)
and get a JUnit report.
© 2022 - 2024 — McMap. All rights reserved.
ctest version 3.25.1
. I'm investigating now. I'll post something here if I found a solution. – Alida