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:
- Create a git repository within bitbucket.
- Create a file named main.cpp within the git repository's root folder, with these contents (this is just a minimal example taken from https://stackoverflow.com/a/21688776):
#include <cstdlib>
int main() {
std::exit(-1);
}- Create another file named CMakeLists.txt in the same folder with these contents (taken from the previous example from https://stackoverflow.com/a/21688776):
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
- Create a bitbucket-pipelines.yml file in the same folder with these contents. The docker image is irrelevant, as long as it has some build-essential packages (C++ compiler) and a "new" cmake version (>=3.21):
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
- Push this repository onto the bitbucket's remote. Bit bucket should start a new pipeline job.
- Upon the pipeline ending, it reports 0 tests on the job, even though some unit tests are generated within a folder whitelisted to detect unit tests.
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