I have c++/c application with a lots of unit tests. I would like to get overall coverage and also individual coverage of each test with condition that each test can be run o
It seems you're using gcovr. Since version 4.2, gcovr can merge its JSON reports with the -a option. So you could do:
# run test1
./test1
gcovr ... --xml coverage-test1.xml --json coverage-test1.json
find . -type f -name '*.gcda' -exec rm {} +
# run test2
./test2
gcovr ... --xml coverage-test2.xml --json coverage-test2.json
find . -type f -name '*.gcda' -exec rm {} +
# combine JSON reports
gcovr -a coverage-test1.json -a coverage-test2.json --xml coverage-combined.xml