Skip to content

Commit

Permalink
Merge pull request #33 from iamdanfox/fix-testClassesDirs
Browse files Browse the repository at this point in the history
Ensure the TestTask contains the right classes
  • Loading branch information
tkrullmann authored Jun 22, 2017
2 parents a022c5a + 0551b46 commit 86b7671
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ class TestTaskListener {
if (testTask.metaClass.respondsTo(testTask, "getTestClassesDirs")) {
// Gradle 4.0+
// See https://docs.gradle.org/4.0/release-notes.html#detecting-test-classes-for-custom-test-tasks
map('testClassesDirs') {
def sourceSet = (SourceSet) project.sourceSets[testSet.sourceSetName]
sourceSet.output.classesDirs
}
def sourceSet = project.sourceSets[testSet.sourceSetName]
testTask.testClassesDirs = sourceSet.output.classesDirs
} else {
map('testClassesDir') {
def sourceSet = (SourceSet) project.sourceSets[testSet.sourceSetName]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,15 @@ class TestTaskTest extends Specification {
def junitXmlReportDir = project.file(testTask.reports.junitXml.destination)
junitXmlReportDir == new File(project.testResultsDir, 'myTest')
}


def "testClassesDirs should include the custom test set (in Gradle 4.0)"() {
when:
project.testSets { myTest }
then:
def testTask = project.tasks['myTest'] as Test
testTask.testClassesDirs[0] == project.sourceSets.myTest.output.classesDirs.singleFile
testTask.testClassesDirs.files.size() == 1
}
}

0 comments on commit 86b7671

Please sign in to comment.