From the TestNG doc I can see that (enabled = false)
can be applied to a class or method. But it seems it only works when applied to a method.
Anybody seen the same, found a solution?
It seems to work for me:
@Test(enabled = false)
public class B {
public void btest1() {
System.out.println("B.btest1");
}
}
Result:
===============================================
SingleSuite
Total tests run: 0, Failures: 0, Skips: 0
===============================================
Changing false to true:
B.btest1
===============================================
SingleSuite
Total tests run: 1, Failures: 0, Skips: 0
===============================================
Here is what might be tripping you (hard to tell since you didn't provide any code):
@Test(enabled = false)
public class B {
@Test
public void btest1() {
System.out.println("B.btest1");
}
}
This case will run the test because by repeating the @Test
annotation on the method, you are also overriding the enabled
attribute to its default value, which is true
.
The solution is to reiterate enabled=false
at the method level:
@Test(enabled = false)
public class B {
@Test(enabled = false)
public void btest1() {
System.out.println("B.btest1");
}
}
I'm aware it's a bit counterintuitive but it's necessary in order to be consistent in the way method annotations can override class annotations.
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