While unit-testing, is there a way to enable code-coverage analysis only during some steps?
I wish to measure the code-coverage of the assert part of a test. The tools that I currently use don't make the difference if the line is executed during the Action-part of the test, or during the assert-part.
Accordingly, I cannot check if all the getter of my beans are read by the assert method. Ideally I want to activate the covering measure only during the execution of some of my methods.
A sample of code:
//method to test
void runToTest(Bean myBean){
myBean.setA(1);
myBean.setB(2);
aString=myBean.getA()+myBean.getB();
}
@Test
void should_check_all_field(){
myBean=new Bean()
myService.runToTest(myBean);
assertMethode();
}
void assertMethod(){
Assert.assertNotNull(myBean.getA())
}
Currently, the tools I use report than getA and getB are covered. I want a way to detect that getB hasn't been read by the assertMethod.
I use Java and IntelliJ and my test class follows the Arrange-Act-Assert syntax.