Datadriven multiline

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Datadriven multiline

qaquest
Hi,
Just getting interested in STF. Read a bit & ready to check it out. Before that had question regarding data-driver...is there a provision to read multiline data?
What I mean is in a test there maybe a scenario wherein a particular function/method needs to be executed multiple times with different data each iteration...yes, what I'm asking is the provision for iteration with a test.
Rgds.
Reply | Threaded
Open this post in threaded view
|

Re: Datadriven multiline

softwaretestingforum
Administrator
of course you can run same test method with different data sets. Just make sure that you provide a different test id. You could see an example here -

https://github.com/tarun3kumar/seleniumtests/blob/master/src/test/resources/com/seleniumtests/tests/loginuser.csv


~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Datadriven multiline

qaquest
Appreciate your prompt response, Tarun.
The idea here is to run multiple sets of data for a given test.
If the driver does this, then it can be used off the bat, otherwise will have to be tweaked to read multiple lines. Eg:
TC_ID SubIteration     SearchTerm
TC1              1               Cat
TC1              2               Dog

There is a bit more, but wanted to check this out 1st before discussing the next level.

Reply | Threaded
Open this post in threaded view
|

Re: Datadriven multiline

softwaretestingforum
Administrator
Is not it same as the example I posted earlier?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Datadriven multiline

qaquest
should have mentioned in my earlier response...your link is giving me 404 error.
Based on what you mentioned "Just make sure that you provide a different test id", I assumed that you are reading 1 line per test.
Let me know if it's otherwise.
Reply | Threaded
Open this post in threaded view
|

Re: Datadriven multiline

softwaretestingforum
Administrator
Sorry I noticed it now that link is broken. Seem an extra word is appended at the end of URL (;cid=1439363576712-833) -

github.com/tarun3kumar/seleniumtests/blob/master/src/test/resources/com/seleniumtests/tests/loginuser.csv;cid=1439363576712-833

correct URL is -

github.com/tarun3kumar/seleniumtests/blob/master/src/test/resources/com/seleniumtests/tests/loginuser.csv

You may like to checkout following project which is based on STF -

github.com/tarun3kumar/seleniumtests/

Hope this helps.


~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Datadriven multiline

qaquest
Pulled the sample project...good stuff!
Now, getting to my need...looked the sample csv, under "TestEntity.TestCaseId" you have unique entries. My need is little different:
TC_ID SubIteration     SearchTerm
TC1             1               Cat
TC1             2               Dog
TC2               1               Car
TC3               1               John
TC3               2               Doe
TC3               3               Mary

You see how there can be 1 or more iterations within 1 test.
Once you answer this, there is a further question.
Reply | Threaded
Open this post in threaded view
|

Re: Datadriven multiline

softwaretestingforum
Administrator
Not right now, you need to provide different test case ids to be able to run test with different data sets.

Though implementation should not be difficult. TestEntity object needs to have one more instance variable called SubIteration. Feel free to fork the project and submit pull requests.


So what's your other question ?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Datadriven multiline

qaquest
Ok.
Right now, do not have the window to work on it, need to get something going pretty soon, so was looking for something off the bat.
The other piece is further into this...basically sub-iteration was meant for feeding data into a method more than once. This next part is about a complete iteration for the test, wherein all the methods are executed for another set of data.
So, we may have something like this:
Test_Id     Iter     Sub_Iter
TC1           1        1
TC2           1        1
TC2           1        2
TC3           1        1
TC3           1        2
TC3           2        1

Nice exchanging views with you, hopefully you'll have time to build on this. Ideally, we get something like this into core Selenium itself, would be great, but STF is also good enough as it's a dependency in POM.
Appreciate your effort.
Reply | Threaded
Open this post in threaded view
|

Re: Datadriven multiline

softwaretestingforum
Administrator
You should be able to do this by using unique testcase_id

In my personal experience, relating manual test case with one on one automation cases may not be feasible/practical. Hence I would suggest to run your test with different data set while setting a different test case id.

You can also use default TestNG data provider to feed same method with different datasets and ignore the approach we discussed above -

http://testng.org/doc/documentation-main.html

hth
~ seleniumtests.com