Integration test resources in a multi project


(waldemar.rittscher) #1

Hi guys,

I love Gradle and I hope you can help me with this, cuz’ I can’t find a solution. I have a multi project setup and a standard configured integration test sourceset. The dependencies of the integration test sourceset is

integrationTestCompile sourceSets.main.output
integrationTestCompile configurations.testCompile

Now I have something like :

@Bean
public SpringLiquibase liquibase() {
      SpringLiquibase liquibase = createLiquibaseBean("classpath:/liquibase/changeLogMasterTest.xml", true);
      liquibase.setDataSource(dataSource);
      return liquibase;
}

This file is in the integration test resources directory of the “repository project” (The “rep pro” creates the database, all database related files are there). All integration tests of the “repository project” are successfull because the file is on the classpath.

Now I have a “service project” and also a integration test source set. The “service project” does not have a “liquibase/changeLogMasterTest.xml” on the classpath but the context configuration of the “service project” references the configuration of the “repository project”. This means if I start the integration test of “service project” I’ll get a exception “/liquibase/changeLogMasterTest.xml is not on the classpath”.

I hope u understand my question. Short version: My integration tests are failing in other projects cuz’ they reference all the database configuration of the repository project but they dont have the necessary files on the classpath.

If I change it to

@Bean
public SpringLiquibase liquibase() {
      SpringLiquibase liquibase = createLiquibaseBean("classpath:/liquibase/changeLogMaster.xml", true);
      liquibase.setDataSource(dataSource);
      return liquibase;
}

It works. This file is inside the main source set of the repo project. And the integraiton test has a dependency to the main source set. But I don’t want to have my integration test related files in the main source set. So I need something like

integrationTestCompile sourceSets.main.output
integrationTestCompile sourceSets.integrationTest.output
integrationTestCompile configurations.testCompile

But this does not make any sence :).

Please help, I’m really tired and frustrated.

Edit:

Further information. This is my integration task

task integrationTest(type: Test) << {
    testClassesDir = sourceSets.integrationTest.output.classesDir
    classpath = sourceSets.integrationTest.runtimeClasspath
}

Very simple


(waldemar.rittscher) #2

Well. Found a solution. My approach was a bad design and I got rid of the liquibase bean. I’ve created a ant task. :slight_smile: