Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diffCoverage gives html report with "No class files specified." #65

Closed
tinder-shivangshah opened this issue Aug 23, 2022 · 3 comments
Closed

Comments

@tinder-shivangshah
Copy link

jacocoTestReport generates the code coverage report. However, diffCoverage generates html file with "No class files specified." I suspect the issue is with classesDirs and srcDirs but unable to get proper report after trying multiple different approaches.

jacocoTestReport {
    reports {
        xml {
            enabled true
            destination file("${buildDir}/coverage-report/jacoco-report.xml")
        }
        html {
            enabled true
            destination file("${buildDir}/coverage-report")
        }
    }
    afterEvaluate {
        classDirectories.from = files(classDirectories.files.collect {
            fileTree(dir: it, exclude: [
                    '**/generated/**'
            ])
        })
    }
}

diffCoverageReport {
    diffSource {
        git.compareWith 'refs/remotes/origin/main'
    }

    jacocoExecFiles = files(jacocoTestReport.executionData)
    classesDirs = files(jacocoTestReport.classDirectories)
    srcDirs = files(jacocoTestReport.sourceDirectories)

    reports {
        html = true
        baseReportDir = "${buildDir}/coverage-report"
    }
}
@Bai-X
Copy link

Bai-X commented Nov 7, 2022

Hi I encountered the same problem, how did you fix it?

@dbwiddis
Copy link

srcDirs = files(jacocoTestReport.sourceDirectories)

Hey @Bai-X I'm having the same issue. I've determined the "No class files specified" stems from an empty diff. I've tried using:

diffSource.git.compareWith 'refs/remotes/origin/main'

But this results in an empty diff.patch file.

I've been able to get it working by manually creating the patch file, e.g.,

$ git diff refs/remotes/origin/main > git.diff

And then using

diffSource.file = 'git.diff'

So it seems there's some bug with the git.compareWith syntax, or we're doing it wrong.

@dbwiddis
Copy link

Seems the changed files actually have to be committed for git.compareWith to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants