renatoathaydes / spock-reports

This project creates a global extension to Spock to create test reports.
Apache License 2.0
273 stars 68 forks source link

Allow to specify a list of testSourceRoots for vivid reports #220

Closed albloptor closed 2 years ago

albloptor commented 2 years ago

Some projects use two separate test sourceSets. In my case, I use test for unit tests and integrationTest. In both cases, I use Spock.

Currently, the property com.athaydes.spockframework.report.testSourceRoots only seems to support a single value, which means that it's not possible to display the sources in the reports for both unit and integration tests.

I've tried setting the property to src, which didn't work. And I believe that would have defeated the purpose of having the property.

In my opinion it would be great to support a list of test sources rather than a single one. This could be useful for people that use Spock for different kind of tests.

renatoathaydes commented 2 years ago

You're right, it should be possible to have more than one root.

I will look into it.

renatoathaydes commented 2 years ago

Hi @albloptor , I fixed this issue... but I noticed that the current version of spock-reports already allows you to provide multiple roots by separating the paths with the File.pathSeparator which is ; on Windows and : on other OSs.

albloptor commented 2 years ago

Hey, thanks for taking care of it so fast. That current solution wasn't obvious to me. I'll try it! What would be the alternative approach given your new solution?

renatoathaydes commented 2 years ago

I've just released spock-reports 2.2.0-groovy-3.0 on Maven Central which contains this fix.

As I explained in the news, you can now use String, File, Closure producing one of the other types, or Iterable whose items are of the other types.

Example:

testSourceRoots = ['src/test/groovy', 'src/testInt/groovy']
testSourceRoots = file('src/test/groovy')
// compute the roots lazily
testSourceRoots = {
    file(someLazyProperty)
}