Friday 15 August 2014

Include/Exclude Only Selected Test Methods from class Test Suite Using testng.xml





Its possbile we can include or exclude selected test method from any class.


1) Create new package and classes as below

TestNGOnePack(package) -> TestNG_Test1.java

2) And BaseClassOne.java have before methods

TestMethod1(),TestMethod2(),TestMethod3()



3) Include test method from class for execution


<suite name="TestNG_Suite">
<test name="TestNG_Test">
<classes>
<class name="TestNGOnePack.TestNG_Test1"></class>
<methods>
<include name="TestMethod1"> </include>
<include name="TestMethod2"> </include>
</methods>
</classes>
</test>
</suite>



From above example, we execute only TestMethod1 and TestMethod2 in execution. But the TestMethod3 is not executed.




4) Exclude Test Method from class for execution.


<suite name="TestNG_Suite">
<test name="TestNG_Test">
<classes>
<class name="TestNGOnePack.TestNG_Test1"></class>
<methods>
<exclude name="TestMethod1"> </exclude>   
</methods>
</classes>
</test>
</suite>



From above example, we execute only TestMethod2(),TestMethod3() in execution. But TestMethod1() is exclude from execution. So its not executed.

No comments:

Post a Comment