0
   @Test(dataProvider="LInData",dataProviderClass=LInDataProvider.class)
public void testLIn(String fname) throws InterruptedException// return 3 fname and this test executed 10 times
{
    System.out.println("test start");

    System.out.println("fname:"+fname);     

        System.out.println("test completed");
}

@Test(dataProvider="LInData",dataProviderClass=LInDataProvider.class)
public void me(String fname,String lname,String em,String pass) 
{
   System.out.println("Other tests");
}

It produces this result:

fname:andy

fname:jack

fname:palm

other tests

But I need below one, Please tell me how can I get below o/p:

fname:andy

other tests

fname:jack

other tests

fname:palm

other tests

1 Answers1

1

It's the perfect case for factories!

public class MyTest {

   private final String fname
   private final String lname;
   private final String em;
   private final String pass;

   @Factory(dataProvider="LInData",dataProviderClass=LInDataProvider.class)
   public MyTest(String fname, String lname, String em, String pass) {
      // init attributes
   }     

   @Test
   public void testLIn() throws InterruptedException // return 3 fname and this test executed 10 times
    {
        System.out.println("test start");        
        System.out.println("fname:" + fname);
        System.out.println("test completed");
    }

    @Test(dependsOnMethods = {"testLIn"})
    public void me() {
       System.out.println("Other tests");
    }
}
juherr
  • 5,640
  • 1
  • 21
  • 63
  • I used this logic but I does not get expected o/p. First test runs for number of times data supplied and then other test. For Example: If dataProvider is having 3 set of data, then testLIn() runs thrice and then me() once. But I want me() to be executed with data set. like one time testLIn() and thenme() – Anand Kumar Jun 09 '16 at 12:41
  • Got the solution: https://drive.google.com/file/d/0B1oPK9QjUy_FSGtVemllLVplRzA/view?usp=sharing – Anand Kumar Jun 09 '16 at 13:18
  • You should use your solution as answer of the question and accept it. It will close the question. – juherr Jun 09 '16 at 13:25