Skip to content

Instantly share code, notes, and snippets.

@elderfo
Created February 20, 2018 18:20
Show Gist options
  • Save elderfo/08bff7eb0f65743abbf7fa521a567a6a to your computer and use it in GitHub Desktop.
Save elderfo/08bff7eb0f65743abbf7fa521a567a6a to your computer and use it in GitHub Desktop.
Integration Test Source Set for Gradle
apply plugin: 'java'
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
sourceSets {
integrationTest {
java.srcDir file('src/integration-test/java')
resources.srcDir file('src/integration-test/resources')
compileClasspath += sourceSets.main.output + sourceSets.test.output + configurations.testRuntime
runtimeClasspath += sourceSets.main.output + sourceSets.test.output + configurations.testRuntime
}
}
task integrationTest(type: Test) {
group 'Verification'
description 'Runs the integration tests.'
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
}
@kyxap
Copy link

kyxap commented Jul 23, 2019

Does it still work?
How do you set dependencies with this config?
For example:

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    integrationTestCompile group: 'junit', name: 'junit', version: '4.12'
}

I'm getting:
> Could not find method integrationTestCompile() for arguments [{group=junit, name=junit, version=4.12}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

@Bwvolleyball
Copy link

@kyxap - there isn't anything wrong with the plugin configuration, but you will need to add a dependency handler in order to be able to add additional dependencies for the source set. An example if this were a Kotlin DSL build gradle:

fun DependencyHandler.integrationTestApiDependenciesMetadata(dependencyNotation: Any): Dependency? =
    add("integrationTestApiDependenciesMetadata", dependencyNotation)

@idrabenia
Copy link

Hi,

There are possible to add all described staff by single line with this plugin.
https://github.com/Softeq/itest-gradle-plugin
https://softeq.github.io/itest-gradle-plugin/

- Ilya

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment