change the tags @Beforeclass and @AfterClass to @Before and @After respectively.
Now your initSimulator () method will be called before every @Test, and after it the quitDriver () method will be called. Thus, you will have a new driver (with a transparent application), reloaded in each case.
So - as you can see - in JUnit, each test case is independent by default.
Why did your problem arise? From @ Docs BeforeClass :
Sometimes, several tests must share an expensive computing setup (such as entering a database). Although this can jeopardize the independence of the tests, sometimes it is a necessary optimization. Annotating the public static void no-arg method with @BeforeClass reasons it runs once before any of the testing methods in the class.
By the way, my initDriver () method looks like this, this is the best way to handle driver rejection:
public void quitDriver() { driver.closeApp(); driver.quit(); driver = null; }
(in your case it is static)
source share