Quantcast

[testng-dev] Behavior of skipException

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[testng-dev] Behavior of skipException

Tulsi tester
Hi All,


I am using TestNg along with datadriven framework. I have a Testcase suite of 3 test case

1. TestCaseOne
2. TestCaseTwo
3. TestCaseThree

I am writing 3 different java classes for the above 3 tests with a Base Test.


BaseTest.java
===========


public class BaseTest extends SeleneseTestBase{

public Data_Reader suite = null;
@BeforeClass
public void suiteInitiation(){
suite = new Data_Reader(System.getProperty("user.dir").concat("\\src\\test\\java\\datadriven\\TestSuite.xlsx"));
}
}


TestOne.java
============
public class TestOne extends BaseTest {

int rowNum=1;
@BeforeClass
public void beforeTestOne(){
System.out.println("Entered Test one");

}
@Test
public void testOne(){
rowNum=2;
boolean one = TestUtil.isTestCaseRunnable(suite, "TestOne");
if(!one){
suite.setCellData("Test Cases", "Result", 2, "Skip");
throw new SkipException("Skipped One");
}
System.out.println("Not skipped");
verifyTrue(true);
checkForVerificationErrors();
}
}


TestTwo.java
==========

public class TestTwo extends BaseTest{

@BeforeClass
public void beforeTestTwo(){
System.out.println("Entered Test two");
// boolean is = TestUtil.isTestCaseRunnable(suite, "TestTwo");
//
// if(!is){
// suite.setCellData("Test Cases", "Result", 3, "skip");
// throw new SkipException("Skipped Two");
// }
// System.out.println("not skipeed two");
}
@Test
public void testTestTwo(){
int rowNum=3;
boolean is = TestUtil.isTestCaseRunnable(suite, "TestTwo");
if(!is){
suite.setCellData("Test Cases", "Result", 3, "skip");
throw new SkipException("Skipped Two");
}
System.out.println("not skipeed two");
Assert.assertFalse(true);
}
@AfterMethod
public void afterMethodTwo(ITestResult result){
int re = result.getStatus();
String stat ="";
if(re==1){
stat="PASS";
}else if(re==2){
stat="FAIL";
}else if(re==3){
stat="Skip";
}
suite.setCellData("Test Cases", "Result", rowNum, stat);
}
}

TestThree.java
============
public class TestThree extends BaseTest{

@BeforeClass
public void beforeTestThree(){
System.out.println("Entered Three");
// boolean is = TestUtil.isTestCaseRunnable(suite, "TestThree");
//
// if(!is){
// suite.setCellData("Test Cases", "Result", 4, "skip");
// }
// System.out.println("not skipped three");
}
@Test
public void testThestThree(){
int rowNum = 4;
boolean is = TestUtil.isTestCaseRunnable(suite, "TestThree");
if(!is){
suite.setCellData("Test Cases", "Result", 4, "skip");
}
System.out.println("not skipped three");
Assert.assertTrue(true);
}
@AfterMethod
public void afterMethodThree(ITestResult result){
int re = result.getStatus();
String stat ="";
if(re==1){
stat="PASS";
}else if(re==2){
stat="FAIL";
}else if(re==3){
stat="Skip";
}
suite.setCellData("Test Cases", "Result", 2, stat);
}
}

TestNg.xml
=========

<test name="TstNg">
<classes>
<class name="datadriven.TestOne"></class>
<class name="datadriven.TestTwo"></class>
<class name="datadriven.TestThree"></class>
</classes>
</test>


If I have TestOne as NO run mode and the remaining two as YES. I am not able to execute the remaining YES test cases and update the status in excel.

Please guide me what is the actual context of skipException. 

Attachment for TestSuite








--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-dev.
For more options, visit https://groups.google.com/d/optout.

TestSuite.xlsx (11K) Download Attachment
Loading...