I have a test case as below:
@Test
public void checkSomething()
{
//line1
//line2
//line3
//line4[Exception occurs here]
//line5
//line6
//line7 homepage.Logout();
}
Now if an exception occurs in line4 for example, then my application will never logout[line7]. This will cause my further test cases to fail since they will not be able to login since user session will be active. How do i make it possible that logout always happen when a test fails prematurely?
I tried putting the logout logic in @AfterMethod. It works fine but is that the best practice to write test code in a configuration method like @AfterMethod?
Aucun commentaire:
Enregistrer un commentaire