jeudi 8 octobre 2015

Passing input from Excel to test class

I have a multiple test cases in single class. Test Excel has three different worksheets/tabs 1, 2 and 3. There are three test cases in my test class.

I looked into data provider annotation; what I understood is it will execute same test case for whole object passed. In my case it will test test case 1 first for all rows from tab 1, test case 2 for all rows from tab 2 and so on.

What I am looking for is as below:

    for i number of rows in excel 
     Execute test 1 with row i from tab 1
     Execute test 2 with row i from tab 2
     Execute test 3 with row i from tab 3
     (Form i complete, proceed to second form data)

What I could do is read the whole Excel put it in object[][]. Create data providers for each test case and let them run in for loop. For example:

    CLASS
    {
     for loop 
      {
          data provider 1, 2, 3;
          @Test
          function testcase1()
          @Test
          function testcase2()
          @Test
          function testcase3()
       }
     }

Is it valid approach or does it defeat the purpose of TestNG?

Aucun commentaire:

Enregistrer un commentaire