2

When I am running a test using Gradle the test will run multiple times. Actually it is running the same amount of times as the number of suites covering that test.

So when running:

gradle test --tests com.mycompany.test.SomeTest

The test will run 3 times. see the following example:

public class SomeTest {
    @Test
    public void test() {
        System.out.println("SomeTest.test --");
    }
}


@RunWith(Suite.class)
@Suite.SuiteClasses({SomeTest.class})
public class SomeSuit1 {}


@RunWith(Suite.class)
@Suite.SuiteClasses({SomeTest.class})
public class SomeSuit2 {}

The output will be:

shay$ gradle test --tests com.mycompany.test.SomeTest 
Starting a Gradle Daemon, 2 busy Daemons could not be reused, use --status for details
:compileAspect UP-TO-DATE
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestAspect
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
Done cleaning report folder [reports]

com.mycompany.test.SomeSuit1 > com.mycompany.test.SomeTest.test STANDARD_OUT
    SomeTest.test --

com.mycompany.test.SomeSuit2 > com.mycompany.test.SomeTest.test STANDARD_OUT
    SomeTest.test --

com.mycompany.test.SomeTest > test STANDARD_OUT
    SomeTest.test --

BUILD SUCCESSFUL

Total time: 20.219 secs

How can I run this specific test only one time?

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
Shay_t
  • 163
  • 1
  • 16
  • Try `gradle test --tests com.mycompany.test.SomeTest.test`. If it works, tell me and I make this an answer for you to accept. Btw. you should always and everytime use the Gradle wrapper for each and every project, even the tiniest one. ;-) – Vampire Jun 20 '17 at 11:54
  • Could you please fix the title of your question and capitalization used in your question? – Maarten Bodewes Jun 20 '17 at 11:54
  • @Vampire "gradle test --tests com.mycompany.test.SomeTest.test." have the same effect – Shay_t Jun 20 '17 at 12:07
  • Then I guess it is not possible. You could open a thread in the Gradle forum about this to get feedback from the Gradle guys directly. – Vampire Jun 20 '17 at 12:11
  • @MaartenBodewes i have done my best, sorry for my bad english. – Shay_t Jun 20 '17 at 12:13
  • @Shay_t Doing your best is good enough, we'll take care of the rest. :) Feel free to re-edit or even roll back your question in case I messed something up. – Maarten Bodewes Jun 20 '17 at 14:02

0 Answers0