1

I need to execute a testNG test method (testA) just after another test method(testB) has been executed. Also I want to annotate testA with @Test because I want to tell testNG that it is a test method not a configuration method.

I was able to do with @AfterMethod but testNG was treating testA as a configuration method which I don't want it to.

Also I need to execute testA just after testB has been executed. I don't want another test to run in between. How do I do this?

1 Answer 1

2

Use

@Test (dependsOnMethods={"methodB"}) public void methodA () { } 

See also http://testng.org/doc/documentation-main.html#dependent-methods

Sign up to request clarification or add additional context in comments.

4 Comments

what if now I have another test testC and just after testC is executed also I need to execute testA?
think you could name both methodB and methodC in dependaOnMethods ... can't try it out atm though... more general advice: don't do this if you don't have too, usually atomic testcases are preferable...
ok thanks for the advise.. bdw is testC guaranteed to be executed just after testB? i mean with dependsOnMethods option?
Sorry not sure about that, docs don't state that explicitly, guess you'll have to try it out

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.