TestNg With Selenium WebDriver : Using Regular Expression To Include/Exclude Test Method From Execution

It is rattling of import for us to know the each together with every agency of testng.xml configuration to include/exclude selected seek out methods or packages inwards execution. You tin thought my posts to know how to include/exclude SELECTED PACKAGE or SELECTED TEST METHODS from selenium webdriver seek out suite execution. There is too i about other agency of including or excluding selected seek out method using regular expression. Let me depict it amongst i uncomplicated example.

For that yous postulate to configure "TestNGOne" projection using iii packages every bit shown inwards THIS POST. Now allow nosotros configure testng.xml file.

Including/Excluding seek out methods using regular expression

Supposing, I wants to Include testmethodtwo() from TestNGOnePack -> ClassOne.java file together with Exclude testmethodtwo() from TestNGTwoPack -> ClassTwo.java file using regular expression. For that my testng.xml file configuration volition endure looks similar bellow.

<suite name="Suite One">   <test name="Test One" >   <classes>    <class name="TestNGOnePack.ClassOne">     <methods>      <include name=".*two.*"/>     </methods>    </class>    <class name="TestNGTwoPack.ClassTwo">     <methods>      <exclude name=".*two.*"/>     </methods>    </class>   </classes>  </test> </suite>

If yous run across inwards in a higher house testng.xml file, ".*two.*" is regular appear used for seek out methods. Means seek out methods containing "two" discussion volition endure considered for inclusion/exclusion inwards seek out suite execution.. Now when I volition piece of job inwards a higher house testng.xml file, Selenium webdriver seek out execution study volition looks similar bellow.


If yous run across inwards in a higher house given seek out execution report, alone 2 methods has been executed every bit per our expectation. This agency yous tin purpose regular expressions for method's inclusion or exclusion.
More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM

http://www.software-testing-tutorials-automation.com/
Post a Comment (0)
Previous Post Next Post