Unit test are not running


(waldemar.rittscher) #1

Hi there,

I have a strange problem and no idea how to fix it. I have a simple multi project setup. Every project just declares it dependencies and some task. Nothing special.

Parent project

|_ Project 1 Frontend

|_ Project 2 Service layer

|_ Project 3 Database

Every project has a build.gradle of course. But if I start now ‘gradle test’ it says ‘Build successful’ but the tests didn’t run. I don’t have any reports… Same for integration test task… I don’t know why it’s not working, there is no crazy configuration.

Any ideas?

Kr


(Peter Niederwieser) #2

We’d really need more information. A few things that you can try:

  • Check the ‘–info’ and ‘–debug’ logs * Check that class files exist in ‘build/classes/test’ * If you are using TestNG, don’t forget the ‘useTestNG()’

If you need more help, provide the relevant parts of your build scripts, or a reproducible example.


(waldemar.rittscher) #3

Thanks for the quick answer - nice. I’m using junit

My settings file:

include ':toolkit-core', ':toolkit-data', ':toolkit-frontend'

Just a simple line

----------------------------------- Parent build file is

allprojects {
 apply plugin: 'idea'
 group = 'com.toolkit'
}
  subprojects {
 apply plugin: 'java'
 sourceCompatibility = '1.7'
      repositories {
        maven {
            url 'http://repo.springsource.org/libs-snapshot'
        }
        mavenCentral()
    }
      sourceSets {
        integrationTest {
            java.srcDir file('src/integration-test/java')
            resources.srcDir file('src/integration-test/resources')
        }
    }
      idea {
        module {
            testSourceDirs += file('src/integration-test/java')
            testSourceDirs += file('src/integration-test/resources')
        }
    }
      List springDependencies = [
            'org.springframework:spring-context:3.1.2.RELEASE'
    ]
      List testDependencies = [
            'org.hamcrest:hamcrest-all:1.3',
            'org.springframework:spring-test:3.1.2.RELEASE',
            'org.mockito:mockito-all:1.8.4'
    ]
      List loggingDependencies = [
            'org.slf4j:slf4j-api:1.6.6',
            'org.slf4j:jcl-over-slf4j:1.6.6',
            'org.slf4j:log4j-over-slf4j:1.6.6',
            'ch.qos.logback:logback-classic:1.0.6'
    ]
      List miscellaneousDependencies = [
            'cglib:cglib-nodep:2.2',
            'org.projectlombok:lombok:0.11.6',
            'joda-time:joda-time:2.1',
            'com.google.guava:guava:13.0.1'
    ]
      dependencies {
        compile springDependencies, loggingDependencies, miscellaneousDependencies
          testCompile testDependencies
        testCompile ('junit:junit:4.10') {exclude module: 'hamcrest-core'}
          integrationTestCompile sourceSets.main.output
        integrationTestCompile configurations.testCompile
    }
      task integrationTest(type: Test) {
        testClassesDir = sourceSets.integrationTest.output.classesDir
        classpath = sourceSets.integrationTest.runtimeClasspath
    }
      configure(integrationTest) {
        group = "Verification"
        description = "Runs all integration tests."
    }
      check.dependsOn integrationTest
}

----------------------------------- Core build file is (i take this. the other look nearly the same)

version = '1.0'
  dependencies {
    compile project(':toolkit-data')
}
  compileJava.dependsOn (':toolkit-data:build')

If I start ‘gradle test’ inside the core project it does not start any tests but says ‘Build successful’… Link to log file is log.txt. It contains the debug output.


(waldemar.rittscher) #4

Well I tried something: I copied the core project in a tmp dir and added the whole parent configuration inside the core build file (to make this project a single project and not part of a multi project). Than I started gradle tests and the test are running… It seems that my multi project setup is incorrect. But it’s nothing special… Same as the sample project and the docs.


(Peter Niederwieser) #5

I suggest to compare your configuration with ‘samples/java/withIntegrationTests’ in the full Gradle distribution. There are some differences - for example, you don’t put ‘sourceSets.test.output’ on the ‘integrationTestCompile’ class path. One of those differences may be the problem.


(waldemar.rittscher) #6

Ok I try. But I’m not sure I want this. Because I don’t need the output of the integrationtest to be in the classpath of the integrationtests - no need for it. Why should this have any impact on my unit tests?

But thanks! I try this of course. I come back and post the result…


(Richard Riley) #7

Did you solve this?