Parameterized in JUnit | Selenium Forum
M
Posted on 21/08/2016
I'm attaching my entire project file.
I'm trying to build a DataDriver Framework of "http://demo.guru99.com/v4/index.php' - this is a demo site from Guru99 Bank.

It should be run as below :

1. Login to the system with Username and password as given in LoginTest.
2. Create New Customer with new customer details as given in NewCustomer excel.
3. Edit customer with details as given in EditCustomer excel - but in this test, the customer number must be the same, which is generated in NewCustomer test.

Here I have 6 java files, LoginTest,NewCustomer,EditCustomer,TestBase,TestUtil and MyTestSuiteRunner.

LoginTest,NewCustomer,EditCustomer - all these are having @Parameters annotation to supply data from excel.

In NewCustomer.java, I have written a code to write customer no in EditCustomer excel file as soon as new customer is created.

Now the problem is, in MyTestSuiteRunner, I have provided 3 java class name in order of Login.class, NewCustomer.class, EditCustomer.class. Now Selenium is reading all the @Parameter annotation at the very begining, that is before executing @Test in LoginTest file also. Hence my purpose is not serving, that is while NewCustomer file is writing in EditCustomer excel, before that Selenium had already read the data from EditCustomer excel and it is supplying the old customer no already present in that excel.

So is there a way by which we can restrict selenium that only after NewCustomer file is executed, then only @Parameter should be run in EditCustomer File. Please help!!!

I have tried with @DataProvider(Junit) as well, but it is also having the same prob.

M
Replied on 22/08/2016

is there a reason you're using junit? why not testng?


M
Replied on 22/08/2016

No, I was just trying to build a Data Driven Framework using JUnit, never thought of such kind of problem might occur. Is there no way to resolve this?

And also If I use TestNG and DataProvider to supply value, then for this same scenario would it work??


M
Replied on 22/08/2016

[quote:lngiggqi]And also If I use TestNG and DataProvider to supply value, then for this same scenario would it work??
[/quote:lngiggqi]

it will not work.

truth be told junit is obsolete everybody uses testng.


M
Replied on 22/08/2016

So could you please suggest, how to handle this scenario in TestNG?


M
Replied on 22/08/2016

Using TestNG my goal is being achieved....
@DataProvider is being read after NewCustomer.java executed..... Responsive image
Thanks!!!


M
Replied on 23/08/2016

[quote="RakeshG":1yfar6vd]Using TestNG my goal is being achieved....
@DataProvider is being read after NewCustomer.java executed..... Responsive image
Thanks!!![/quote:1yfar6vd]
glad to hear it.