Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

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

Posted on 11/09/2024 By admin

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.

Example:

package DataProvider;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
 
public class DataProviderWithIndices {
   
        
        
        // You must need to mention data provider method name in Test method
        @Test(dataProvider="DataContainer")
    public void studentRegistration(String First_name, String Last_Name, String Email_ID) {
        System.out.println("Registered student with details: "+First_name+" "+Last_Name+" "+Email_ID);    
      
    }
     
        
        /*
         * Since we have set parallel as true, test method will be run in parallel for set of data provided by data provider. 
         */
    @DataProvider(name="DataContainer", parallel=true)
    public Object[] myDataProvider() {
        
        
        Object data[][]=  new Object[5][3];
        // First student details
        data[0][0]= "Mukesh"; 
        data[0][1]= "Otwani";
        data[0][2]= "[email protected]";
        
        // Second student details
        data[1][0]= "Amod";
        data[1][1]= "Mahajan";
        data[1][2]= "[email protected]";
        
        // Third student details
        data[2][0]= "Animesh";
        data[2][1]= "Prashant";
        data[2][2]= "[email protected]";
        
        // Fourth student details
        data[3][0]= "Ankur";
        data[3][1]= "Singh";
        data[3][2]= "[email protected]";
        
        // Fifth student details
        data[4][0]= "Amritansh";
        data[4][1]= "Kumar";
        data[4][2]= "[email protected]";
        
        return data;
        
        
    }
}

Output:

[java] [RemoteTestNG] detected TestNG version 6.14.2 Registered student with details: Mukesh Otwani [email protected] Registered student with details: Amod Mahajan [email protected] Registered student with details: Amritansh Kumar [email protected] Registered student with details: Ankur Singh [email protected] Registered student with details: Animesh Prashant [email protected] PASSED: studentRegistration(“Mukesh”, “Otwani”, “[email protected]”) PASSED: studentRegistration(“Ankur”, “Singh”, “[email protected]”) PASSED: studentRegistration(“Amod”, “Mahajan”, “[email protected]”) PASSED: studentRegistration(“Amritansh”, “Kumar”, “[email protected]”)

PASSED: studentRegistration(“Animesh”, “Prashant”, “[email protected]”)

Uncategorized

Post navigation

Previous Post: TestNG Tutorials – Page 7
Next Post: TestNG Tutorials 43: Difference Between “Parameters” and “parameter” in TestNG

Related Posts

May 5, 2018 – Make Selenium Easy Uncategorized
CalTable – Make Selenium Easy Uncategorized
allAreWebElements – Make Selenium Easy Uncategorized
REST Assured Tutorial 16 – Building RequestSpecification Using RequestSpecBuilder Uncategorized
Amod Mahajan, Author at Make Selenium Easy – Page 3 of 51 Uncategorized
JVMWindows – Make Selenium Easy Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark