Skip to content

Commit

Permalink
migrate to testkit
Browse files Browse the repository at this point in the history
  • Loading branch information
rpalcolea committed Nov 10, 2023
1 parent 4aa27fa commit a580c77
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
package nebula.plugin.responsible

import nebula.test.IntegrationSpec
import nebula.test.functional.ExecutionResult
import org.gradle.api.Plugin
import org.gradle.api.Project
import nebula.test.IntegrationTestKitSpec

/**
* Runs Gradle Launcher style integration Spock tests on the NebulaIntegTestPlugin class
*/
abstract class AbstractNebulaIntegTestPluginLauncherSpec extends IntegrationSpec {
abstract class AbstractNebulaIntegTestPluginLauncherSpec extends IntegrationTestKitSpec {

String fakePackage = "nebula"

abstract Class<Plugin<Project>> getPluginClass()
abstract String getPluginId()

def setup() {
writeTest('src/integTest/java/', fakePackage, false)
writeResource('src/integTest/resources', 'integTest')
buildFile << """
plugins {
id 'java'
id '${getPluginId()}'
}
apply plugin: 'java'
${applyPlugin(getPluginClass())}
repositories {
mavenCentral()
Expand All @@ -36,31 +36,31 @@ abstract class AbstractNebulaIntegTestPluginLauncherSpec extends IntegrationSpec

def "compiles integration test classes"() {
when:
runTasksSuccessfully('integrationTest')
runTasks('integrationTest')

then:
fileExists("build/classes/java/integTest/$fakePackage/HelloWorldTest.class")
}

def "copies integTest resources"() {
when:
runTasksSuccessfully('integrationTest')
runTasks('integrationTest')

then:
fileExists('build/resources/integTest/integTest.properties')
}

def "runs the integration tests"() {
when:
runTasksSuccessfully('integrationTest')
runTasks('integrationTest')

then:
fileExists("build/integTest-results/TEST-${fakePackage}.HelloWorldTest.xml")
}

def "builds the integration test report"() {
when:
runTasksSuccessfully('integrationTest')
runTasks('integrationTest')

then:
fileExists('build/reports/integTest/index.html')
Expand Down Expand Up @@ -88,7 +88,7 @@ abstract class AbstractNebulaIntegTestPluginLauncherSpec extends IntegrationSpec

writeHelloWorld('nebula.plugin.plugin')
writeTest("src/$NebulaIntegTestPlugin.FACET_NAME/java/", 'nebula.plugin.plugin', false)
runTasksSuccessfully('idea')
runTasks('idea')

then:
File ideaModuleFile = new File(projectDir, "${moduleName}.iml")
Expand All @@ -105,4 +105,8 @@ abstract class AbstractNebulaIntegTestPluginLauncherSpec extends IntegrationSpec
orderEntries.find { it.library.CLASSES.root.@url.text().contains('bar-2.4.jar') }
orderEntries.find { it.library.CLASSES.root.@url.text().contains('baz-5.1.27.jar') }
}

boolean fileExists(String path) {
new File(projectDir, path).exists()
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
package nebula.plugin.responsible

import nebula.test.functional.ExecutionResult
import org.gradle.api.Plugin
import org.gradle.api.Project

/**
* Runs Gradle Launcher style integration Spock tests on the NebulaIntegTestPlugin class
*/
class NebulaIntegTestPluginLauncherSpec extends AbstractNebulaIntegTestPluginLauncherSpec {
@Override
Class<Plugin<Project>> getPluginClass() {
return NebulaIntegTestPlugin.class
String getPluginId() {
return 'com.netflix.nebula.integtest'
}

def "check depends on integration test task"() {
when:
ExecutionResult result = runTasksSuccessfully('check')
def result = runTasks('check')

then:
result.wasExecuted(':test')
result.wasExecuted(':integrationTest')
result.task(':test').outcome
result.task(':integrationTest')?.outcome
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import org.gradle.api.Project
*/
class NebulaIntegTestPluginStandaloneLauncherSpec extends AbstractNebulaIntegTestPluginLauncherSpec {
@Override
Class<Plugin<Project>> getPluginClass() {
return NebulaIntegTestStandalonePlugin.class
String getPluginId() {
return 'com.netflix.nebula.integtest-standalone'
}

def "check does not depend on integration test task"() {
when:
ExecutionResult result = runTasksSuccessfully('check')
def result = runTasks('check')

then:
result.wasExecuted(':test')
!result.wasExecuted(':integrationTest')
result.task(':test').outcome
!result.task(':integrationTest')?.outcome
}
}

0 comments on commit a580c77

Please sign in to comment.