Run the clean
command for whatever build tool you are using (ant, maven, gradle).
If you only run the jacocoTestReport
occasionally, you might want to add a dependency on clean
for it, to ensure it always happens before generating the report.
I noticed this same problem when I changed a package name on a class and the old package was still in the report.
What is happening is the report that is created is simply a bunch of files that follow the naming and package convention of the files in your project. So files from a previous run of jacocoTestReport
are still sitting in that report folder, even though you have deleted the java file, and rerun jacocoTestReport
. If you look in the folder, you will find the timestamp is older on the report file for the deleted class than the others around it. It just needs the clean
so that your next run will only contain files related to the current report.
I assume its possible to change where jacocoTestReport
will write its report files and if you choose somewhere other than the build directory, you would need to update your clean
task to clean up that area too.