I Have a piece of a really simple code.
Something like:
public class Foo {
public void bar() {
timer.start();
try{
///
} finally {
timer.stop();
}
}
}
I have a unit test that runs with Mockito and when I use IntelliJ option for code-coverage it marks the line in the finally
as not covered. The thing is that it happens only when I throw an exception inside the try
. The even more weird issue is that I have an assert that makes sure the call in the finally
block was called:
Mockito.verify(timer).stop(); // timer is mocked here of course
When I run debug, the debugger stops in this line.
When I run a test without an exception in the finally
block - the coverage marks it as covered.
What am I missing here?