I don\'t have much experience with TestNG annotations, however I am trying to build a test suite using TestNG framework and POM design pattern for a retail website. I am plannin
The best solution I have found, We can check the run mode of the Suite in @BeforeTest Annotation method if it found N, Then throw new skip Exception, it will skip all the test case of that suite, I was doing a mistake to catch the Exception in try catch block that's why it was going to check all the test cases after throw skip exception.
Please find below the right example how to skip all the test cases in a suite, if suite run mode found as N in suite Excel. running this through testng.xml
package com.qtpselenium.suiteC;
import org.testng.SkipException;
import org.testng.annotations.BeforeSuite;
import com.qtpselenium.base.TestBase;
import com.qtpselenium.util.TestUtil;
public class TestSuiteBase extends TestBase{
@BeforeSuite
public void checksuiteskip(){
try {
//Initialize method of Test BASE Class to Initialize the logs and all the excel files
Initialize();
} catch (Exception e) {
e.printStackTrace();
}
App_Logs.debug("checking run mode of SuiteC");
if( !TestUtil.isSuiterunnable(suitexlsx, "suiteC")){
App_Logs.debug("Run mode for suiteC is N");
throw new SkipException("Run mode for suiiteC is N");
}else
App_Logs.debug("Run mode for SuiteC is Y");
}
}