Clover can measure code not only code coverage from whole application run but also a coverage generated by a single test case (JUnit / TestNG). It is possible to "hack" Clover and measure per-test coverage from manual test cases too. What has to be done is to "tell" Clover when manual test case starts and ends.
The easiest way to provide this information is to write a JUnit test case, with one test method for each manual test case. Clover will add "start test / end test" instrumentation to such methods. Next it's necessary run such JUnit test together with the application - thanks to the Clover's Distributed Coverage feature it's possible to run JUnit test and the application under test in separate JVMs.
1) Write JUnit test case having following features:
- tests do not start until application under test is launched
- one test method per one manual test case
- single test method starts just before corresponding manual test case is started
- single test method ends just after corresponding manual test case is finished
2) Compile JUnit test case together with the application under test (produce two jars, for instance) with a Distributed Coverage feature enabled.
- flushpolicy = interval or threaded might be needed
3) Run unit test and application:
a) unit test shall be launched with -Dclover.server=true parameter, e.g.
b) application shall be launched as usual (note that distributed coverage configuration is already compiled into instrumented classes), e.g.
Browsing per-test coverage
4) Generate coverage report. In the HTML report it's possible to browse coverage contributed by given test case(s) by clicking "Show tests" link on the class summary page.
Per-test optimization for manual tests
Because of fact that all manual test cases were wrapped into JUnit tests it's possible use per-test optimization:
- create test optimization snapshot file after test execution (<clover-snaphsot/> task)
- after code base changes, run optimized test set (using the <clover-optimized-testset/>selector
for <junit/> task)
- note that Clover-for-Ant optimization is based on test classes, not test methods (it's a limitation of <junit> <batchtest>) so it' might be worth to have one test method per test class
It is also possible to browse "source file - test case" and "class file - test case" mapping using the SnapshotPrinter tool:
SnapshotPrinter can print mapping in plain text or in JSON format.