TestNG Tutorial
Introduction to TestNG Configuration and set up of TestNG project Simple TestNG project in IntelliJ IDEA TestNG annotations Assertions in TestNG Difference between assertEquals and assertSame Ignoring the tests in TestNG Grouping the tests timeOut tests in TestNG Exception tests in TestNG dependsOnMethods dependsOnGroups Hard and Soft dependencies Passing parameters using XML file Passing parameters using Data providers Dynamic Data Providers group-by-instances attribute in TestNG XML suite file Test priorities in TestNG invocationCount in TestNG Executing Selenium tests using TestNG Executing TestNG tests using main method Executing JUnit tests from within TestNG Running tests in Parallel in TestNG Executing only failed tests in TestNG TestNG integration with Maven TestNG integration with Gradle Reporter class in TestNG TestNG Reports Execution Listener Test Listener Comparison between JUnit and TestNGRunning tests in parallel in testng
By default, all tests are run sequentially in TestNG. But we can also execute tests in Parallel. In TestNG suite XML file, we can specify how you want to execute tests in parallel way. We can execute tests in parallel in below ways.- tests – Tests configured inside test tags are run in parallel.
- classes – Tests from multiple classes are executed in parallel.
- methods – Methods are executed in parallel.
- instances – Test methods of Class Instances are executed in parallel.
<suite thread-count="3" name="mytestSuite" parallel="tests">
In below example, parallel attribute’s value is classes. It means that tests from org.softpost.Class1 and org.softpost.Class2 would be executed in parallel.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite" parallel="classes" thread-count="2">
<test name="Tests">
<classes>
<class name="org.softpost.Class1" />
<class name="org.softpost.Class2" />
</classes>
</test>
</suite>
Web development and Automation testing
solutions delivered!!