Determining which test cases covered a method

前端 未结 2 688
北海茫月
北海茫月 2021-01-14 23:34

The current project I\'m working on requires me to write a tool which runs functional tests on a web application, and outputs method coverage data, recording which test case

2条回答
  •  一生所求
    2021-01-15 00:06

    Have you looked at existing coverage tools (Cobertura, Clover, Emma, ...). I'm not sure if one of them is able to link the coverage data to test cases, but at least with Cobertura, which is open-source, you might be able to do the following:

    • instrument the classes with cobertura
    • deploy the instrumented web app
    • start a test suite
      • after each test, invoke a URL on the web app which saves the coverage data to some file named after the test which has just been run, and resets the coverage data
    • after the test suite, generate a cobertura report for every saved file. Each report will tell which code has been run by the test

    If you need a merged report, I guess it shouldn't be too hard to generate it from the set of saved files, using the cobertura API.

提交回复
热议问题