Awesome
Gradle Integration Testing Plugin
There are plugin that allow to configure integration tests same way as unit tests in simple way
Build
To build the project it is require to execute
./gradlew clean build
Documentation
Content:
- Quick Start
- Source Set
- Integration Test Task
- Dependencies Management
- Skip Tests
- Configurable Parameters
Quick Start
To add itest plugin to your project it will require to add next code to the build.gradle
plugins {
id 'com.softeq.gradle.itest' version '1.0.4'
}
Or with Kotlin
plugins {
id("com.softeq.gradle.itest") version "1.0.4"
}
After that you will have possibilities to write tests to the itest/ folder.
To run the tests you just need to execute in your project
./gradlew clean build
Source Set
There are by default application add new source set to the project with name itest
.
To change name of the source set it is possible to use name
configuration parameter. In this case location of
integration test sources will be at folder with specified name.
With Groovy / Kotlin
itestSourceSet {
name = "integrationTest"
}
Also there are possible to customize compile classpath and runtime classpath of the source set
Groovy
itestSourceSet {
name = "integrationTest"
compileClasspath = sourceSets.main.compileClasspath
runtimeClasspath = sourceSets.main.runtimeClasspath
}
Kotlin
itestSourceSet {
name = "integrationTest"
compileClasspath = sourceSets["main"].compileClasspath
runtimeClasspath = sourceSets["main"].runtimeClasspath
}
Integration Test Task
Current plugin also configure task integrationTest
that extends standard Test
task of the Gradle.
Configuration parameters for this task you may find
there
JUnit 5
To add support of JUnit 5 you will require to specify at configuration task
Groovy
integrationTest {
useJUnitPlatform()
}
Kotlin
tasks.withType<Test> {
useJUnitPlatform()
}
TestNG
To use TestNG for integration testing of you application it will require to specify next configuration for the
integrationTest
task
Groovy
integrationTest {
useTestNG()
}
Kotlin
tasks.withType<Test> {
useTestNG()
}
Spock
To use Spock framework with the plugin it will require just to add the Spock dependencies
Groovy / Kotlin
dependencies {
itestImplementation("org.spockframework:spock-core:1.3-groovy-2.5")
}
Dependencies Management
There are possible to specify additional dependencies for the integration test classes
Standard Configuration | itest Configuration | Description |
---|---|---|
implementation | itestImplementation | Implementation dependencies scope |
compileOnly | itestCompileOnly | Compile Only dependencies scope |
runtimeOnly | itestRuntimeOnly | Runtime Only dependencies scope |
You can specify this dependencies in the dependencies
section of the build.gradle
file
Groovy
dependencies {
itestRuntimeOnly 'com.h2database:h2:1.0.60'
}
Kotlin
dependencies {
itestRuntimeOnly("com.h2database:h2:1.0.60")
}
Skip Tests
To skip integration tests you need to provide -PdisableIntegrationTests
option to the gradle.
For instance
gradlew clean build -PdisableIntegrationTests
Alternative options to disable integration and unit tests you can find below
gradlew clean build -x test -x integrationTest
Configurable Parameters
There are table with available plugin configuration parameters
Param | Parent Configuration | Default Value | Description |
---|---|---|---|
name | itestSourceSet | "itest" | There are name of the folder with integration test sources |
compileClasspath | itestSourceSet | Main SourceSet output and classpath | There are classpath of the compiler to build integration tests |
runtimeClasspath | itestSourceSet | Main SourceSet output and runtime classpath | There are runtime classpath that will be used during integration tests evaluation |
Gradle Test Params | integrationTest | - | There are standard Gradle Test task configuration |
useJUnitPlatform() | integrationTest | - | There are option to enable JUnit 5 tests execution |
useTestNG() | integrationTest | - | There are option to enable TestNG evaluation support |
License
MIT