Gradle multiproject tests not getting invoked

I have a project having subprojects in the following structure

|-- project1
    |
 -- src
     ..
    |
 -- resources
    |
 -- test
    |-- project2
     ..
    |-- build.gradle
    |-- gradle.properties
    |-- settings.gradle
    |-- weblogic.gradle

For project1, I have some test cases written in TestNG which are not getting invoked.

Here is by build script

apply plugin: 'war'
    apply plugin: 'ear'
    apply plugin: 'java'
    ...
    project(':project1') {
        ...
        dependencies{
            ...
       compile 'org.testng:testng:6.8.8'
            compile 'com.jayway.restassured:rest-assured:2.3.2'
        }
        test{
            useTestNG()
            testLogging.showStandardStreams = true
        }
        ...
    }
      project(':project2') {
        ..
    }
    ...

The tests are working when tried from an IDE. Also the build script works for other tasks like build and deploy. Only test is failing. Another observation was that when defining dependency, the test jars are getting downloaded only when i say compile. It doesnt download for testCompile.

When i execute gradle test ,It says Build Successful. But I dont see any test output on terminal nor report getting generated

Gradle version used is 2.0

Any help will be appreciated

Looking at the way your described your project structure it seem like you have your ‘test’ directory as a peer of ‘src’. By default, the expectation is for your project structure to look like:

project1

|-- src

|-- main

|-- java

|-- resources

|-- test

|-- java

|-- resources

Additionally, you should use the ‘testCompile’ configuration when declaring dependencies for your test code.

dependencies{

testCompile ‘org.testng:testng:6.8.8’

testCompile ‘com.jayway.restassured:rest-assured:2.3.2’

}

Mark, that was a mistake in my post. The structure is as you have explained. I dont find an edit option to correct it. Also testCompile didnt download the dependencies. So I tried compile and it downloaded

It may be that you simply omitted it from your post but are you applying the ‘java’ plugin to your subprojects? If so, is your test code being compiled? What happens when you do

$ gradle :project1:testClasses

My bad. I had actually place the test inside main. failed to notice it even when you posted the structure last time. Thanks!