TestNG Tutorial #20 – How to Manage Dependency Between Test Cases

In this TestNG tutorial we will learn how to manage Dependency Between Test Cases.

In some scenarios, you might need your test methods to be invoked in specific order. For example, you want to ensure some of the tests are completed and successful before launching other tests. TestNG dependencies help you in achieving this behavior.

TestNG allows you to specify dependencies either with annotations or in XML. To manage dependencies with annotations, you can use the attributes dependsOnMethods or dependsOnGroups, found on the @Test annotation.

There are two kinds of dependencies:

✅ Hard dependencies

✅ Soft dependencies