Skip to content

Commit

Permalink
Added integration test that checks compatibility with different Gradl…
Browse files Browse the repository at this point in the history
…e versions
  • Loading branch information
tkrullmann committed Jul 9, 2017
1 parent d86a47c commit 079886c
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 2 deletions.
29 changes: 27 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,39 @@ repositories {
}


dependencies {
compile gradleApi()
sourceSets {
integrationTest
}


configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntime.extendsFrom testRuntime
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
}


dependencies {
testCompile('org.spockframework:spock-core:1.0-groovy-2.4') {
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
}
testCompile 'org.hamcrest:java-hamcrest:2.0.0.0'
}


gradlePlugin {
testSourceSets sourceSets.integrationTest
}


task integrationTest(type: Test) {
dependsOn pluginUnderTestMetadata
group = 'verification'
description = 'Runs the integration tests.'
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
}


apply from: "$rootDir/publishing.gradle"
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.unbrokendome.gradle.plugins.testsets

import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import org.junit.Rule
import org.junit.rules.TemporaryFolder
import spock.lang.Specification
import spock.lang.Unroll


class GradleVersionsCompatibilityTest extends Specification {

@Rule TemporaryFolder projectDir

File buildFile


def setup() {
buildFile = projectDir.newFile('build.gradle')

buildFile << '''
plugins {
id 'org.unbroken-dome.test-sets'
}
testSets {
integrationTest
}
'''
}


@Unroll
def "Plugin should work in Gradle #gradleVersion"(String gradleVersion) {
when:
def result = GradleRunner.create()
.withGradleVersion(gradleVersion)
.withProjectDir(projectDir.root)
.withPluginClasspath()
.withArguments('integrationTest', '--stacktrace')
.withDebug(true)
.forwardOutput()
.build()
then:
result.task(':integrationTest').outcome in [ TaskOutcome.NO_SOURCE, TaskOutcome.UP_TO_DATE ]

where:
gradleVersion << [ '4.0', '3.5', '3.3', '3.2.1', '2.14.1' ]
}
}

0 comments on commit 079886c

Please sign in to comment.