-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix JGiven Plugin to be a cacheable task
- Loading branch information
1 parent
b8409a9
commit 5de67e4
Showing
3 changed files
with
102 additions
and
35 deletions.
There are no files selected for viewing
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
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
67 changes: 67 additions & 0 deletions
67
jgiven-gradle-plugin/src/test/groovy/com/tngtech.jgiven.gradle/JGivenPluginShould.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,67 @@ | ||
package com.tngtech.jgiven.gradle | ||
|
||
|
||
import com.google.common.io.Resources | ||
import org.gradle.testkit.runner.GradleRunner | ||
import org.junit.Rule | ||
import org.junit.rules.TemporaryFolder | ||
import spock.lang.Specification | ||
|
||
import static org.gradle.testkit.runner.TaskOutcome.FROM_CACHE | ||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS | ||
|
||
class JGivenPluginShould extends Specification { | ||
|
||
@Rule | ||
TemporaryFolder testProjectDir = new TemporaryFolder() | ||
File buildFile | ||
|
||
def setup() { | ||
buildFile = testProjectDir.newFile('build.gradle') | ||
} | ||
|
||
def "test is cacheable"() { | ||
given: | ||
buildFile << """ | ||
plugins { | ||
id 'java' | ||
id 'com.tngtech.jgiven.gradle-plugin' | ||
} | ||
repositories { jcenter() } | ||
dependencies { | ||
testImplementation 'com.tngtech.jgiven:jgiven-junit:1.0.0-RC4' | ||
testImplementation 'junit:junit:4.12' | ||
} | ||
""" | ||
|
||
testProjectDir.newFolder("src", "test", "java") | ||
File scenario = testProjectDir.newFile("src/test/java/SimpleScenario.java") | ||
scenario << Resources.toByteArray(Resources.getResource("SimpleScenario.java")) | ||
|
||
when: | ||
def result = GradleRunner.create() | ||
.withProjectDir(testProjectDir.getRoot()) | ||
.withArguments("--build-cache", "test", "jgivenTestReport") | ||
.withPluginClasspath() | ||
.build() | ||
|
||
then: | ||
result.task(":test").outcome == SUCCESS | ||
result.task(":jgivenTestReport").outcome == SUCCESS | ||
|
||
when: | ||
new File(testProjectDir.root, 'build').deleteDir() | ||
result = GradleRunner.create() | ||
.withProjectDir(testProjectDir.getRoot()) | ||
.withArguments("--build-cache", "test", "jgivenTestReport") | ||
.withPluginClasspath() | ||
.build() | ||
|
||
|
||
then: | ||
result.task(":test").outcome == FROM_CACHE | ||
result.task(":jgivenTestReport").outcome == FROM_CACHE | ||
|
||
} | ||
} |