Is there a method by which we can control the running of a test case

Is there a method by which we can control the running of a test case

Hi Charity,

Yes, there is a way by which you can do exactly what you want. This is known as dependency in testNG.

Dependency is when you have a function which needs to run after a particular function/s completes testing. By this you can do exactly the same as you require.

All you need to do is make a test function dependent.

@Test (dependsOnMethods= "h2" )

public void h1()

{

System.out.println("test case 1");

}

@Test

public void h2()

{

System.out.println("test case 2");

}

@Test

public void h3()

{

System.out.println("test case 3");

}

@Test

public void h4()

{

System.out.println("test case 4");

}

This way h1 will run only when h2 is completed.

Hope this helps.