Is it possible to execute different sets of data in parallel

26 views
Skip to first unread message

Tulsi tester

unread,
Jul 17, 2015, 12:22:15 PM7/17/15
to testng...@googlegroups.com
Hi All,

I have the following requirement. I have 3 sets of data for login functionality for gmail application. I am writing one test method for login functionality and one data provider method to read the data with parallel=true


@Test(dataprovider="data")
public void testLogin(String username,String password)
{

//need to do login functionality

}

@Dataprovider(name="data", parallel=true)
public object[][] getData(){

   returning data from here
}


and i have the testng.xml as 

<suite name="parallesuite"  parallel="tests" thread-count="4" data-provider-thread-count="10">

<test name="paralletest"  parallel="methods">
<classes>
<class name="hybridframe.RegistrationTest"></class>
</classes>
</test>
</suite>

I am able to start the browsers but facing the problem of input the data. Selenium inputs the complete rows of data as a single row and inserts 3 usernames as single username into one browser. 


Please let me know how to solve this issue.

Krishnan Mahadevan

unread,
Jul 18, 2015, 9:10:35 AM7/18/15
to testng...@googlegroups.com
Tulsi,
As I mentioned in the selenium-users forum, the problem is with your test code.

Your test code must be looking kind of the below for you to experience this problem

public class ASampleClass {
  private WebDriver driver;
  
  @Test(dataprovider="data")
  public void testLogin(String username,String password) {
    driver = new FirefoxDriver();
    
  }
  @Dataprovider(name="data", parallel=true)
  public object[][] getData(){
   //returning data from here
  }  
}

When the above mentioned test method runs in parallel all the threads literally end up sharing the same data member “driver”. You would need to move the variable declaration into your @Test annotated test method for you to get past the problem.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Technical Scribbings @ http://rationaleemotions.wordpress.com/


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

sunny sachdeva

unread,
Jul 20, 2015, 7:13:18 AM7/20/15
to testng...@googlegroups.com

HI Krishnan,

Assuming the same code which you posted, lets say instead of 1 @Test , if i have 100 then it becomes redundant to declare variable under each @Test.

Can we create a generic method which would instantiate webdriver using Thread.Local. I would try this but just want to understand if it would work.

Thanks,
Sunny

krishnan.ma...@gmail.com

unread,
Jul 20, 2015, 8:50:35 AM7/20/15
to testng...@googlegroups.com

Its still going to be the same redundancy. ThreadLocal is basically geared towards thread safety.

-Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else"



Reply all
Reply to author
Forward
0 new messages