TestNG is very useful and powerful framework for selenium webdriver. We need to configure our tests based on our requirements or test scenarios.
Create new package and classes as below
TestNGOnePack(package) -> BaseClassOne.java, ClassOne.java, ClassTwo.java
TestNGTwoPack(package) -> ClassOne.java, ClassTwo.java
TestNGThreePack(package) -> ClassOne.java, ClassTwo.java
Configure testng.xml to run selected packages from all packages of webdriver project in single test suite
From three packages, I wants to run only two packages -> "TestNGTwoPack" and "TestNGThreePack". For that we need to configure testng.xml as bellow.
<suite name="Suite One">
<test name="Test One" >
<packages>
<package name="TestNGTwoPack" />
<package name="TestNGThreePack" />
</packages>
</test>
</suite>
In above example <packages> tag used to describe group of packagesand is used to add specific package in our test suite.
So when you run above testng.xml file, It will run only targeted two packages(TestNGTwoPack, TestNGThreePack). Other (TestNGOnePack)package(s) will be excluded from execution.
Configure testng.xml to run all packages of project in single test suite
If you wants to run all packages of your project, you can configure your testng.xml using wildcard(.*) with package tag as bellow.
<suite name="Suite One">
<test name="Test One" >
<packages>
<package name=".*" />
</packages>
</test>
</suite>
No comments:
Post a Comment