Search code examples
javajunitgradle

Gradle not running tests


For some reason gradle is not running my tests. When i execute gradle cleanTest test -i i get:

Skipping task ':compileJava' as it is up-to-date (took 0.262 secs).
:compileJava UP-TO-DATE
:compileJava (Thread[main,5,main]) completed. Took 0.266 secs.
:processResources (Thread[main,5,main]) started.
:processResources
Skipping task ':processResources' as it has no source files.
:processResources UP-TO-DATE
:processResources (Thread[main,5,main]) completed. Took 0.001 secs.
:classes (Thread[main,5,main]) started.
:classes
Skipping task ':classes' as it has no actions.
:classes UP-TO-DATE
:classes (Thread[main,5,main]) completed. Took 0.0 secs.
:compileTestJava (Thread[main,5,main]) started.
:compileTestJava
Skipping task ':compileTestJava' as it has no source files.
:compileTestJava UP-TO-DATE
:compileTestJava (Thread[main,5,main]) completed. Took 0.001 secs.
:processTestResources (Thread[main,5,main]) started.
:processTestResources
Skipping task ':processTestResources' as it is up-to-date (took 0.004 secs).
:processTestResources UP-TO-DATE
:processTestResources (Thread[main,5,main]) completed. Took 0.007 secs.
:testClasses (Thread[main,5,main]) started.
:testClasses
Skipping task ':testClasses' as it has no actions.
:testClasses UP-TO-DATE
:testClasses (Thread[main,5,main]) completed. Took 0.001 secs.
:test (Thread[main,5,main]) started.
:test
file or directory '/Users/jan/2014-2015-groep-05/VoPro/build/classes/test', not found
Skipping task ':test' as it has no source files.

My test are in the folder ./test/. And this is my gradle config:

apply plugin: 'java'
apply plugin: 'eclipse'

test {
  testLogging {
    events "passed", "skipped", "failed", "standardOut", "standardError"
  }
  dependsOn 'cleanTest'
}

repositories {
  mavenCentral()
}

dependencies {
  testCompile("junit:junit")
}

sourceSets {
  main {
    java {
      srcDir 'src'
      srcDir 'test'
    }
  }
}

I can't seem to find what the problem is. Gradle does not recognize any tests, since both test and cleanTest are always up to date, however i did add test/ to my sourceSets.


Solution

  • You're saying that the main SourceSet should contain the test directory. This directory should be set in the test SourceSet.