Skip to content

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

Description

@grsky360

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions