Set Test Dependencies in TestNG

We can set Test dependencies in TestNG. Dependency is a feature in TestNG that allows a test method to depend on a single or a group of test methods.

TestNG allows you to specify dependencies either with:

  • Using attribute dependsOnMethods in @Testannotations.
  • Using attribute dependsOnGroups in @Testannotations.

 

Facts about dependencies –

  • The dependency on multiple test methods are configured for a test method by providing the comma separated dependent test method names.
  • If a dependent method fails, all the subsequent test methods will be skipped, NOT failed.

 

1. dependsOnMethods() – Let’s understand this concept with a simple example.

 

Video Tutorial:

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

Let’s see the Report. We are displaying TestNG console report here. You can also see these reports in your HTML reports.

Test Dependency in TestNG

 

Lets see,If a dependent method is fail, all the subsequent test methods will be skipped, NOT failed.

We are explicitly failing the test case init() and execute the Test Class.

Test Dependency in TestNG

 

2. dependsOnGroups() – We will see the Test Case grouping in the coming tutorials in details. At the same time we will see, How we can use the dependsOnGroups() method.

0 Comment

Leave a Reply