In my webdriver script I have the three methods
setup, test and tearDown
following the junit convention.
In the test
method I have few asserts like this
@Test
public void testStudentHome() throws Exception {
String classCode = "I6OWW";
Utilities.studentSignin(driver, baseUrl);
assertEquals(true, sth.openNotification());
assertEquals("My Scores", sth.myScores(true));
}
The sth
is the PageObject on which I am performing the tests and that I have created in the setup
method.
I am calling all these three methods from a main
method like this:
public static void main(String[] args) {
StudentHomeTest sht = new StudentHomeTest();
try {
sht.setup();
sht.testStudentHome();
sht.tearDown();
} catch (Exception ex) {
Logger.getLogger(StudentHomeTest.class.getName()).log(Level.SEVERE, null, ex);
sht.tearDown();
}
}
Now while running the test if some assertion fails the test method should (this is what I expect) throw an exception and the main
method should call the tearDown
method. But this does not happen. and the browser window continues to stay there.
I am using the netbeans ide for running the test.