diff-coverage-gradle icon indicating copy to clipboard operation
diff-coverage-gradle copied to clipboard

Wrong class file distinguish when two classes having same package and name

Open grsky360 opened this issue 3 years ago • 5 comments

Describe the bug When there are two java files in different module, that have same package and class name, the coverage is wrong e.g.

  • module A
    • com.example.Application
  • module B
    • com.example.Application

There is no test for both A and B before.

After I changed A class and add related test case

  • Module A pass, because I covered changed lines
  • Module B failed, even I didn't change the file, but it still think the changed line belongs to this file.

I think the root cause is, the plugin didn't add module name for distinguish two different class I don't read the source code, but I think the uniqueKey is

  • Now: package_name + class_name
  • Should be: module_name/parent_dir_name + package_name + class_name

Version info:

  • Gradle version: 4.10.2
  • Diff Coverage plugin version 0.8.1

To Reproduce

diffCoverageReport {
    violationRules.failIfCoverageLessThan 0.7
}
  • module A
    • com.example.Application
  • module B
    • com.example.Application

Both two files don't have test class

Then change module A file, and run diffCoverage

grsky360 avatar Aug 03 '22 09:08 grsky360

Hi @grsky360

Thank you for reporting the issue. It's the known issue since the early days of development of the plugin. Nevertheless, I'll try to fix it.

By the way, it's very important for me to know why do you use so old gradle 4.10.2?

SurpSG avatar Aug 04 '22 21:08 SurpSG

Thank you!

The project is from my company, and there are many dependencies for upgrading from v4 to v5 because there are some breaking changes about classpath

grsky360 avatar Aug 05 '22 07:08 grsky360

Currently, I'm developing some new features for the plugin. I faced with a few breaking changes between v4 and v5 that make impossible supporting older Gradle releases. If possible, force your team upgrading to v5.3 at least. It will bring multiple benefits to your dev team. I'll try to keep the plugin compatible with Gradle v4 or I'll port some critical issues to 0.9.x. By the way, have you tried DiffCoverage 0.9.x? Does it compatible with your project?

SurpSG avatar Aug 05 '22 07:08 SurpSG

I tried 0.9.x, but I met the issue #43 . So I'm still waiting for 0.10.x. Yes, I think 5.x will be better for the project, we're planning upgrading it recently

grsky360 avatar Aug 05 '22 10:08 grsky360

Hi @grsky360

Could you please create a sample project that reproduces the issue?

SurpSG avatar Sep 18 '22 19:09 SurpSG