Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/_GrailsTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ target(allTests: "Runs the project's tests.") {
def rawTypeString = rawType.toString()
if (phaseName == 'integration') {
def mode = new GrailsTestMode(autowire: true, wrapInTransaction: true, wrapInRequestEnvironment: true)
new JUnit4GrailsTestType(rawTypeString, rawTypeString, mode)
new JUnit4GrailsTestType(rawTypeString, rawTypeString, buildConfig.grails.testing.sortFiles, mode)
}
else {
new JUnit4GrailsTestType(rawTypeString, rawTypeString)
new JUnit4GrailsTestType(rawTypeString, rawTypeString, buildConfig.grails.testing.sortFiles)
}
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ class JUnit4GrailsTestType extends GrailsTestTypeSupport {
protected suite
protected mode

JUnit4GrailsTestType(String name, String sourceDirectory) {
this(name, sourceDirectory, null)
JUnit4GrailsTestType(String name, String sourceDirectory, sortFiles) {
this(name, sourceDirectory, sortFiles, null)
}

JUnit4GrailsTestType(String name, String sourceDirectory, GrailsTestMode mode) {
super(name, sourceDirectory)
JUnit4GrailsTestType(String name, String sourceDirectory, sortFiles, GrailsTestMode mode) {
super(name, sourceDirectory, sortFiles)
this.mode = mode
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ abstract class GrailsTestTypeSupport implements GrailsTestType {
*/
final String relativeSourcePath

/**
* Whether to sort the files that make up this test type; boolean,
* or a closure to indicate how they should be sorted
*/
final sortFiles

/**
* The test target patterns that should be used to filter the tests to run
*/
Expand All @@ -61,13 +67,14 @@ abstract class GrailsTestTypeSupport implements GrailsTestType {
/**
* Sets the name and relativeSourcePath
*/
GrailsTestTypeSupport(String name, String relativeSourcePath) {
GrailsTestTypeSupport(String name, String relativeSourcePath, sortFiles) {
[name: name, relativeSourcePath: relativeSourcePath].each {
if (!it.value) throw new IllegalArgumentException("$it.key cannot be empty or null")
}

this.name = name
this.relativeSourcePath = relativeSourcePath
this.sortFiles = sortFiles
}

/**
Expand Down Expand Up @@ -188,6 +195,11 @@ abstract class GrailsTestTypeSupport implements GrailsTestType {
}
}

if (sortFiles instanceof Closure) {
sourceFiles.sort(sortFiles)
} else if (sortFiles) {
sourceFiles.sort()
}
sourceFiles.unique()
}

Expand Down Expand Up @@ -265,4 +277,4 @@ abstract class GrailsTestTypeSupport implements GrailsTestType {
}
}

}
}