An answer with an important explanation:
There are two parameters of "TestNG" who are supposed to determine the order of execution the tests:
@Test(dependsOnGroups= "someGroup")
And:
@Test(dependsOnMethods= "someMethod")
In both cases these functions will depend on the method or group,
But the differences:
In this case:
@Test(dependsOnGroups= "someGroup")
The method will be dependent on the whole group, so it is not necessarily that immediately after the execution of the dependent function, this method will also be executed, but it may occur later in the run and even after other tests run.
It is important to note that in the case and there is more than one use within the same set of tests in this parameter, this is a safe recipe for problems because the dependent methods of the entire set of tests will run first and only then the methods that depend on them.
However, in this case:
@Test(dependsOnMethods= "someMethod")
Even if this parameter is used more than once within the same set of tests, the dependent method will still be executed after the dependent method is executed immediately.
Hope it's clear and helps.