I have following dummy test class
package my.test;
import org.testng.annotations.*;
public class NgScenario {
public static void trace(String msg) {
System.err.println(msg);
}
@BeforeClass
public void init() {
trace("-- NgScenario");
}
@AfterClass
public void shutdown() {
trace("-- NgScenario");
}
@Test(dependsOnMethods = {"step2"})
public void step1() throws Exception {
trace("-- step1");
}
@Test
public void step2() throws Exception {
trace("-- step2");
}
@Test(dependsOnMethods = {"step2"})
public void step3() throws Exception {
trace("-- step3");
}
}
and build.gradle
apply plugin: 'java'
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
compile "org.testng:testng:6.9.10"
}
test {
useTestNG()
scanForTestClasses = false
include '**/*'
beforeTest { descriptor ->
logger.lifecycle("Gradle running test: ${descriptor}")
}
}
When I execute simple command gradle test
- everything is OK and output is following (note: step2
intentionally depends on step1
to check that order is indeed correct):
Gradle running test: Test method step2(my.test.NgScenario)
Gradle running test: Test method step1(my.test.NgScenario)
Gradle running test: Test method step3(my.test.NgScenario)
Now, assuming I have 100 methods in scenario and I want to test-debug in my IDE only single branch of methods - I run command gradle test --tests my.test.NgScenario.step1
and receive this error
No tests found for given includes: [my.test.NgScenario.step1]
step1
has dependsOnMethods
in its annotation. Same command for test without dependsOnMethods
runs OK: gradle test --tests my.test.NgScenario.step2
.
So the question is - what I'm doing/expecting wrong?
I'd like to both use test scenarios and be able to start individual test sub-tree in IDE.
On top of this - it would be nice to be able execute 'step1' without tasks it depends on (assuming 'parent' steps are 'clean+setup' - they are not needed for debugging of single test with all pre-requisites already in-place).
As off-topic - another framework which is able to integrate into gradle build can be recommended.
Try this:
gradle :clean -Dtest.single=Name_of_your_test_here test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With