2

I'm trying to create a new gradle project for just testing some code but I can't run the test cases.

My folder structure looks like this:

- src
    - main
        - groovy
        - java
        - resources
    - test
        - groovy
        - java
        - resources

My build.gradle:

group 'test'
version '1.0-SNAPSHOT'

apply plugin: 'groovy'

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.3.11'
    testCompile group: 'junit', name: 'junit', version: '4.11'
}

and a test, that is in src/test/groovy:

import groovy.util.logging.Log
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@Log
@RunWith(JUnit4.class)
class TestA {
    TestA() {
        println "hello"
    }

    @Test
    void "test"() {
        println "a"
        log.info("b")
    }
}

When I'm running ./gradlew.bat test through the command line I get this:

{ test }  ยป ./gradlew.bat test
:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava UP-TO-DATE
:compileTestGroovy
:processTestResources UP-TO-DATE
:testClasses
:test

BUILD SUCCESSFUL

Total time: 5.333 secs

Everything should be right but nothing gets printed and I don't know why.

Mr.Tr33
  • 838
  • 2
  • 18
  • 42

2 Answers2

1

I got the "problem" ...

./gradlew.bat test is not printing the output. For that it was necessary to add -i at the end

Mr.Tr33
  • 838
  • 2
  • 18
  • 42
-1

Try only this in your gradle:

dependencies {
testCompile 'junit:junit:4.12'}

Shreyansh Patni
  • 401
  • 2
  • 17
  • I already tried that too: `FAILURE: Build failed with an exception. * What went wrong: Cannot infer Groovy class path because no Groovy Jar was found on class path: file collection` โ€“ Mr.Tr33 Sep 28 '16 at 09:13
  • try this if it helps:http://stackoverflow.com/questions/27955574/gradle-build-not-including-source-src-groovy โ€“ Shreyansh Patni Sep 28 '16 at 09:23
  • I guess you mean this: `sourceSets.test.groovy.srcDirs = [ 'src' ]`, but I'm not sure if that would be right and it's not working โ€“ Mr.Tr33 Sep 28 '16 at 09:38