Unit test are not running

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?


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.

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'
      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 = [
      List testDependencies = [
      List loggingDependencies = [
      List miscellaneousDependencies = [
      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.

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.

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.

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…

Did you solve this?