When to use multiple annotations?

Hello everybody,
I saw many examples on the internet with more than one annotation in it.
I am automating my application with just one annotation (i.e, @Test ).
So anybody please explain me how and when to use more than one annotation in my script?

1 Like

Go through http://testng.org/doc/documentation-main.html#annotations

I tried to add 2nd Annotation to my test script (i.e,@AfterTest).
But the IDE shows syntax error.

@jitenderbhardwaj Please share your code snippet, so that I can debug your issue.

@auto-geek i got it.
By the way, thank you. :smile:

@auto-geek Hello buddy,
I learnt how to use multiple annotation in any test script.
But I still have one question in my mind : When to use multiple annotation in any test script.What is the condition at which user has to use multiple annotation in test script.


@jitenderbhardwaj Suppose your test requires opening a connection to the database or start a server session which should be done in @BeforeSuite , actual test steps you will write in @Test , close database connection, stop/kill server or uinstall an app after suite execution will be done in @AfterSuite .
If you have data driver test like login scenario with valid and invalid credentials, then you can use @DataProvider