我需要运行测试类并在屏幕上显示结果,遵循这个结构,但是在运行完所有之后。
@RunWith(Suite.class) @ Suite.SuiteClasses({
LoginTest.class,
LogoutTest.class
})
公共类AllTests {
protected static WebDriver driver;
@BeforeClass
public static void beforeClass() throws Exception {
driver = Selenium.getDriver();
driver.navigate().to(Property.SITE_ADDRESS);
driver.manage().window().maximize();
}
@AfterClass
public static void afterClass() throws Exception {
String resultString = "";
Result result = JUnitCore.runClasses(AllTests.class);
for (Failure fail : result.getFailures()) {
resultString += result.getClass() +": "+ fail.toString()+"\n";
}
if (result.wasSuccessful()) {
resultString += result.getClass() +": "+ result + "\n";
}
JFrame frame = new JFrame("Results");
JOptionPane.showMessageDialog(frame, resultString, "Title", JOptionPane.INFORMATION_MESSAGE);
driver.quit();
}
我的@AfterClass正在重新运行我的测试类,还有其他解决方案吗?