Gradle tests do not work

For some reason, gradle does not work 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 is 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 don’t seem to understand what the problem is. gradle does not recognize any tests, since both tests and cleanTest are always relevant, however I added test / to my source sets.

+10
source share
2 answers

You say that the main sourceSet should contain a test directory. This directory must be installed in the SourceSet test .

+8
source

Replace sourceSets with the following simple snippet:

sourceSets.main.java.srcDirs = ['src']
sourceSets.test.java.srcDirs = ['tst']
0
source

Source: https://habr.com/ru/post/1584657/


All Articles