I have a TestNG test suite that is working fine except for one thing: I cannot run the same test twice. The reason I want to run a test twice is that I am testing web services that log a user in/out, and I want to verify that the login works, then that the logout work, and then log them in again so that the subsequent tests, which require the user to be logged in, can proceed.
Here is the relevant section of my testng.xml:
<suite name="WebServiceTestSuite">
<test name="webServiceTest" verbose="10" parallel="none">
<classes>
<class name="com.abcco.webservice.DivisionTest">
<methods>
<include name="registrationCreateTest"></include>
<include name="registrationActivateTest"></include>
<include name="appUserLoginTest"></include>
<include name="appUserLogoutTest"></include>
<include name="appUserLoginTest"></include>
<include name="sessionValidateTest"></include>
<include name="sessionExtendTest"></include>
</methods>
</class>
</classes>
</test>
</suite>
As you can see, the "appUserLoginTest" is called twice. However, when I debug this I can clearly see that it is only actually run the first time it is called. After that the execution proceeds as if the second line calling it didn't exist.
See Question&Answers more detail:os