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 96694ff
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 136 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()
}
}
Loading

0 comments on commit 96694ff

Please sign in to comment.