0

I've tests where based on some condition, I skip execution in @BeforeClass itself like -

@BeforeClass(alwaysRun = true) public void beforeClass() { if (someCondition) { //do something } else { throw new SkipException("THESE TESTS ARE NOT INTENDED TO EXECUTE: "); } } @BeforeMethod public void beforeMethod() { // do something } 

But I run tests, skipExecution statement is executed still execution goes in method annotated with @BeforeMethod and code under it is executed which results my tests in failure instead of skip status.

Is this known bug in TestNG or issue with TestNG version? I'm using TestNG 6.9.10 version

3
  • An old post suggests that SkipException works in BeforeMethod but not in other configuration methods - stackoverflow.com/questions/21591712/…. You can also skip test methods in runtime by switching the enabled attribute of the Test annotation to false by using the IAnnotationTransformer. - testng.org/doc/documentation-main.html#annotationtransformers and stackoverflow.com/questions/33476985/… (juherr answer) Commented Dec 22, 2017 at 7:01
  • Can you please try again using the latest released version of TestNG [currently it is 6.13.1] ? I am not able to reproduce this issue with it. Commented Dec 25, 2017 at 8:35
  • Yes I also cannot reproduce it with testng 6.9.10 when I separately try it out. But it reproduces with our automation framework. Looks somewhere exception is being caught. Commented Dec 26, 2017 at 5:38

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.