Is there anyway to merge cobertura coverage xml reports together?

后端 未结 5 1868
时光说笑
时光说笑 2021-01-04 02:29

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

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-04 03:23

    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
    

提交回复
热议问题