How does dependency work in testNG?

How does dependency work in testNG?

Hi Charity,

There are times when you need to run a test case when some other test case has been executed. This scenario is attained by using dependency in testNG.

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

TestNG allows you to specify dependencies either with:

Using attribute dependsOnMethods in @Test annotations.
Using attribute dependsOnGroups in @Test annotations.