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

reportScoverage - is there a way to change the name of gradle test task? #89

Open
Coobik opened this issue Feb 20, 2019 · 2 comments
Open

Comments

@Coobik
Copy link

Coobik commented Feb 20, 2019

Hi!
There is a project containing both legacy (spec2) tests and new scalatest tests.
gradle-scalatest plugin with append mode made it possible to run legacy tests with "gradle test" and the new scalatest tests with "gradle scalatest".
looks like gradle-scoverage plugin runs "test" task to measure coverage.

is it possible to change gradle test task name to be run by gradle-scoverage task?

or is it possible to create multiple scoverage tasks like this:
reportScoverage -> test
reportScalatestScoverage -> scalatest

thanks!!

there is some discussion here
#77
but looks like no clear solution is available

@maiflai
Copy link
Contributor

maiflai commented Feb 26, 2019

Hi,

The new release (3.0.0) of this plugin does now run the test task to measure coverage, but it sounds like you want to be able to measure the coverage that results from running both sets of tests?

If so you might try the following snippet (modified from org/scoverage/ScoveragePlugin.groovy:203):

project.gradle.taskGraph.whenReady { graph ->
            if (graph.hasTask(project.reportScoverage)) {
                project.scalatest.configure {
                    project.logger.debug("Adding instrumented classes to '${path}' classpath")

                    classpath = project.configurations.scoverage + instrumentedSourceSet.output + classpath

                    outputs.upToDateWhen {
                        extension.dataDir.get().listFiles(new FilenameFilter() {
                            @Override
                            boolean accept(File dir, String name) {
                                return name.startsWith("scoverage.measurements.")
                            }
                        })
                    }
                }
            }
}

If this works we can see about exposing the functionality in a cleaner way?

Thanks,
Stu.

@eyalroth
Copy link
Contributor

This should be implemented in #100.

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