TestNG Dependencies | TestNG Tutorial

TestNG Dependencies:

Sometimes, you may need to invoke methods in a test case in a certain order. Here comes TestNG Dependencies into the picture.

TestNG allows you to specify dependencies either with annotations or in XML.

First, we see Dependencies with annotations:

TestNG allows you to specify dependencies either with:

  • Using attribute dependsOnMethods in @Test annotations, OR.
  • Using attribute dependsOnGroups in @Test annotations.

Check below video to see “TestNG Dependencies with Annotations”

Please be patient. The video will load in some time.

If you liked this video, then please subscribe to our YouTube Channel for more video tutorials.

testng.xml

Console Output:

Now we add the dependsOnMethods attribute to the @Test Annotations and execute the same program.

See the script below.

Execute the same testng.xml which was placed above and see the difference in Console Output

Console Output:

Let’s see Dependencies with XML:

Check below video to see “TestNG Dependencies with XML”

Please be patient. The video will load in some time.

If you liked this video, then please subscribe to our YouTube Channel for more video tutorials.

testng.xml

Console Output:

You could find the complete TestNG tutorial here.

TestNG Complete Tutorial

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

2 thoughts on “TestNG Dependencies | TestNG Tutorial”

  1. Hi Rajkumar,

    you are doing really well keep it up.

    in the last example testng.xml middle line code should display like

    but it’s displaying

    thank’s
    bharath.b

    • Hi Bharath, I didnt get you. Could you please put your code without these symbols ‘<' and '>‘

Leave a Comment

Share via
Copy link
Powered by Social Snap