How to setup integration tests for tasks in buildSrc?

Hi,

I’m writing some custom gradle tasks to support deploying different software stacks onto AWS. I currently have some tasks like PackageResources, BuildAmi, etc… under the buildSrc directory. I have written tests for these tasks in the test directory but as I go I realize these are mainly integration tests since they really interact with AWS, for instance the BuildAmi task, and can take a signficant amout of time. The consequence is that it is not really feasible for these tests to run as unit tests under buildSrc.

I have been trying various things to try and move these tests to an integrationTest directory still under buildSrc w/o much success. Do you have an example of integration tests for buildSrc tasks that I could look at ?

Maybe my approach is wrong and I really need to start packaging all of this in a plugin. Again an example of a plugin with integration tests baked in would be awesome.

Thanks, Luis

Ok this is what seems to be working for me now. I packaged my tasks as an aws-deployment buildSrc plugin and it has the following build.gradle:

sourceSets {
  integrationTest
}
  dependencies {
  integrationTestCompile sourceSets.main.output
  integrationTestCompile configurations.testCompile
  integrationTestCompile sourceSets.test.output
  integrationTestRuntime configurations.testRuntime
}
  task integrationTest(type:Test) {
  testClassesDir = sourceSets.integrationTest.output.classesDir
  classpath = sourceSets.integrationTest.runtimeClasspath
}

This allows me to run the integrationTest task by cd’ing to the plugin directory and at the same time the task is not run when building a root project task.