Search code examples
javaspringtestingintegrationcode-coverage

Jacoco plugin does not report coverage for renamed integration test class


Let me show you the problem with the following use case:

Let's assume I have class Example and want to use the unit and integration test for that. Once the unit tests in file ExampleTest (with methods annotated by @Test) is done, coverage report displays correct result. Once the integration tests in file ExampleTestInt (with methods annotated by @Test) is done, coverage report does not display correct result. As if the class was excluded from the coverage process.

That means if I have just integration tests for Example class then I cannot see the correct result in coverage by jacoco.

Is there some way how to keep that ExampleTestInt class to be coverage similarly like in case of the unit test? I would like to keep the same name.


Solution

  • I have found out that the root problem was in wrong filename used for integration tests.

    As per my observation the jacoco coverage plugin was looking for files with suffix Test and hence the file ExampleTestInt couldn't be seen by plugin.