TestNG Tutorials 59: DataProvider in TestNG – Running DataProvider Method in Parallel – Parallel DataProvider Method

A Test method is run for all data set provided by a DataProvider method which is by default one after another. Note here that test method is run on data in same sequence in which DataProvider pass it. The reason behind this is that a DataProvider annotated method has an attribute named “parallel” whose default value is set to “false”.

We can run it parallel as well by setting attribute “parallel” value as true. It will save a lot of time.




[RemoteTestNG] detected TestNG version 6.14.2
Registered student with details: Mukesh Otwani Motwani@gmail.com
Registered student with details: Amod Mahajan amahajan@hotmail.com
Registered student with details: Amritansh Kumar akumar@gmail.com
Registered student with details: Ankur Singh asingh@gmail.com
Registered student with details: Animesh Prashant aprashant@gmail.com
PASSED: studentRegistration("Mukesh", "Otwani", "Motwani@gmail.com")
PASSED: studentRegistration("Ankur", "Singh", "asingh@gmail.com")
PASSED: studentRegistration("Amod", "Mahajan", "amahajan@hotmail.com")
PASSED: studentRegistration("Amritansh", "Kumar", "akumar@gmail.com")
PASSED: studentRegistration("Animesh", "Prashant", "aprashant@gmail.com")

    Default test
    Tests run: 5, Failures: 0, Skips: 0

Default suite
Total tests run: 5, Failures: 0, Skips: 0

You can see console output is not in sequence of data provided by DataProvider method. It means it was run parallely.

Parallel data providers running from an XML file share the same pool of threads, which has a size of 10 by default. You can modify this value in the tag of your XML file:

<suite name="Suite1" data-provider-thread-count="20" >

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 4+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went throw so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning