TestNG allows the tests to run in parallel or multi-threaded mode. This means that based on the test suite configuration, different threads are started simultaneously and the test methods are executed in them. This gives a user a lot of advantages over normal execution, mainly reduction in execution time and ability to verify a multi-threaded code.
In this post we will create two testng file as
TestParallelClassOne and TestParallelClassTwo and each containing two methods i.e test case one and test cases two and each test will open different url in firefox browser.
TestParallelClassOne
TestParallelClassTwo as
Now create testng.xml file as
Right click and run as Testng suite.
If we see the output each test is running on different thread.
[TestNG] Running:
/Users/gururaj/workspace/ManipalPro/ParallelRun.xml
Test Case One in TestParallelClassOne with Thread Id:- 10
Test Case One in TestParallelClassTwo with Thread Id:- 11
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Test Case two in TestParallelClassOne with Thread Id:- 10
Test Case Two in TestParallelClassTwo with Thread Id:- 11
===============================================
Parallel test suite
Total tests run: 4, Failures: 1, Skips: 0
===============================================
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.