testClassesDirs() is a mystery


(Stewart Bryson) #1

I’m getting this warning, which there are several discussions about already:

The setTestClassesDir(File) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the setTestClassesDirs(FileCollection) method instead.

However, I can’t seem to understand what it’s looking for. Unless I pass a sourceSets object as described in all the examples, I get the following error. But I should be able to pass the results of a project.files, which is supposed to return a FileCollection object.

testClassesDirs project.files { dir: "/tmp" include: '*' }

Which gives me the following error:

Could not find method testClassesDirs() for arguments [file collection] on task ':obiee/brokerage:regressionBaselineTest' of type obi.gradle.RegressionTestTask

Shouldn’t I be able to hardcode this? My example is a bit of an edge-case, but we are extracting JAR files in downstream smoke-testing workflows, and we need to be able to tell Gradle explicitly where to look for extract test classes.


(Sterling Greene) #2

I think you want (note the =):

testClassesDirs = project.files { dir: "/tmp" include: '*' }

Unless obi.gradle.RegressionTestTask doesn’t extend Test?


(Stewart Bryson) #3

obi.gradle.RegressionTestTask does in fact extend Test. But I tested the = anyway, and got:

Could not set unknown property 'testClassesDirs' for task ':obiee/brokerage:regressionBaselineTest' of type obi.gradle.RegressionTestTask.


(Sterling Greene) #4

Are you sure you’re running with Gradle 4.0?

My quick and dirty test works (gradle help):

task someTest(type: Test) {
   testClassesDirs = project.files { dir="/tmp"; include='*' }
}

class RegressionTest extends Test {}

task regressionTest(type: RegressionTest) {
   testClassesDirs = project.files { dir="/tmp"; include='*' }
}

(Stewart Bryson) #5

Dang. Wrapper was 3.5. My bad. ‘=’ sign did the trick.