CTest, as part of CMake, is a test runner which generates xml reports. Starting with the 3.21 version, they support JUnit generation.
However, this is not detected by bitbucket, in which after a pipeline runs a job with a ctest command on it it reports 0 detected tests. When using other test runners (like GTest) on the same test code, bitbucket correctly reports the number of tests.
How to reproduce:
#include <cstdlib>
int main() {
std::exit(-1);
}
cmake_minimum_required(VERSION 3.21)
project(BitbucketExample)
enable_testing()
add_executable(main main.cpp)
add_test(test1 main)
add_test(test2 main)
set_tests_properties(test2 PROPERTIES WILL_FAIL ON
image:
name: feabhas/gcc11-cmake:latest # this comes from https://hub.docker.com/r/feabhas/gcc11-cmake/
options:
docker: true
clone:
depth: full
pipelines:
default:
- step:
name: Build and check the pipeline unit tests reports
- mkdir buildForCTest
- cd buildForCTest
- cmake ..
- make -j8
- ctest --output-junit test-results/unit_tests_results.xml
I tried to be more or less thorough, but I likely missed some steps. In that case I'll be happy to help :)
Best regards and have a nice day
Hello Francisco,
Thank you for contacting Atlassian Community, my name is Norbert and I'm a Bitbucket Cloud Support Engineer, it's nice to meet with you. Welcome to the Atlassian Community!
This is interesting, please see my Pipelines configuration and the "Build Teardown" section, once the build has finished, it found the test result:
Can you try to compare your bitbucket-pipelines.yml file and my bitbucket-pipelines.yml file and let me know if there's any difference between those builds?
I'm looking forward to hear from you Francisco.
Have a great day!
Best Regards,
Norbert
Atlassian Bitbucket Cloud Support
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.