[英]Jacoco report showing deleted java class for test coverage
I have simply deleted the java class file which was of no use.After building the package in intellij, Jacoco test report showing deleted java class as well.我只是删除了没有用的java类文件。在intellij中构建包后,Jacoco测试报告也显示了已删除的java类。 For reference, I have attached sceenshot.
作为参考,我附上了 sceenshot。
Is there any reference exists even after deleting java class file in intellij.即使在intellij中删除java类文件后,是否存在任何引用? How can I completely resolve this issue?
我怎样才能彻底解决这个问题?
Run the clean
command for whatever build tool you are using (ant, maven, gradle).为您使用的任何构建工具(ant、maven、gradle)运行
clean
命令。
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.如果您只是偶尔运行
jacocoTestReport
,您可能需要为其添加对clean
的依赖,以确保它始终在生成报告之前发生。
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
.因此,即使您已删除 java 文件并重新运行
jacocoTestReport
,先前运行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.它只需要
clean
以便您的下一次运行将只包含与当前报告相关的文件。
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.我认为可以更改
jacocoTestReport
将在哪里写入报告文件,如果您选择构建目录以外的其他位置,则还需要更新您的clean
任务以清理该区域。
The same thing happened to me today.今天同样的事情发生在我身上。 It was due to:
这是由于:
.class
files inside target/
)target/
.class
文件)mvn clean
did not clean those files, since the corresponding module was removed from pom.xml
mvn clean
没有清理这些文件,因为相应的模块已从pom.xml
中删除**/classes
and **/**.exec
, and it doesn't care about .gitignore
or pom.xml
. **/classes
和**/**.exec
,并且它不关心.gitignore
或pom.xml
。 After removing remove the old files, the coverage reported by Jacoco changed.删除删除旧文件后,Jacoco 报告的覆盖率发生了变化。
I used git clean -f -d --dry-run
to look for old folders, and removed them with git clean -f -d
.我使用
git clean -f -d --dry-run
来查找旧文件夹,并使用git clean -f -d
删除它们。 Please be careful with this command!请小心使用此命令!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.