-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #157 - Add test cases to verify ordering
- Loading branch information
1 parent
7354997
commit fb9035d
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
grails-testing-support/src/test/groovy/grails/testing/spock/JUnitAnnotationSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package grails.testing.spock | ||
|
||
import org.junit.jupiter.api.AfterAll | ||
import org.junit.jupiter.api.AfterEach | ||
import org.junit.jupiter.api.BeforeAll | ||
import org.junit.jupiter.api.BeforeEach | ||
import spock.lang.Shared | ||
import spock.lang.Specification | ||
import spock.lang.Stepwise | ||
|
||
@Stepwise | ||
class JUnitAnnotationSpec extends Specification { | ||
@Shared | ||
static List<String> methodOrder = [] | ||
|
||
void setupSpec() { | ||
methodOrder << "setupSpec" | ||
} | ||
|
||
void setup() { | ||
methodOrder << "setup" | ||
} | ||
|
||
void cleanup() { | ||
methodOrder << "cleanup" | ||
} | ||
|
||
void cleanupSpec() { | ||
methodOrder << "cleanupSpec" | ||
} | ||
|
||
@BeforeEach | ||
void beforeEach() { | ||
methodOrder << "beforeEach" | ||
} | ||
|
||
@AfterEach | ||
void afterEach() { | ||
methodOrder << "afterEach" | ||
} | ||
|
||
@BeforeAll | ||
static void beforeAll() { | ||
methodOrder << "beforeAll" | ||
} | ||
|
||
@AfterAll | ||
static void afterAll() { | ||
methodOrder << "afterAll" | ||
assert methodOrder == ["beforeAll", "setupSpec", "beforeEach", "setup", "cleanup", "afterEach", "cleanupSpec", "afterAll"] | ||
} | ||
|
||
void 'junit 5 annotated methods are called in correct order prior to this test'() { | ||
expect: | ||
methodOrder == ["beforeAll", "setupSpec", "beforeEach", "setup"] | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
grails-testing-support/src/test/groovy/grails/testing/spock/OnceBeforeSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters