我正在使用 Junit5 和 TestFX 编写应用程序测试。我的意图是主测试类在每次测试后重新启动应用程序。据我所知,我将使用注释@BeforeEach,它对我不起作用。
这是我的测试课:
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class MainTest extends ApplicationTest implements FxRobotInterface {
Logger loggerGuiTesting = LoggerManager.getInstance().getLogger(LoggerType.GUI_TESTING);
@BeforeEach
@Override
public void start(final Stage stage) {
StartMain.getInstance();
this.loggerGuiTesting.log(Level.INFO, "Application starts!");
}
@AfterAll
public void endApplication() {
new ExitGuiTest().run(); // That's my internal test framework
}
@Test
public void atestIfOpeningScreenIsThere() {
verifyThat("#imageViewSplashScreenLogo", NodeMatchers.isNotNull());
verifyThat("#progressBarSplashScreen", NodeMatchers.isNotNull());
verifyThat("#labelSplashScreenVersion", NodeMatchers.isNotNull());
verifyThat("#labelSplashScreenDate", NodeMatchers.isNotNull());
this.loggerGuiTesting.log(Level.INFO, "testIfOpeningScreenIsThere, succeeded!");
}
@Test
public void btestIfRadioButtonOneExist() {
assertThat("#sourcesOneRadioButton", is("#sourcesOneRadioButton"));
this.loggerGuiTesting.log(Level.INFO, "testIfRadioButtonOneExist, succeeded!");
}
@Test
public cnextTest() {
new StartAnotherGuiTest().run();
this.loggerGuiTesting.log(Level.INFO, "anotherTest, succeeded!");
}
}
问题是:如何在每次测试后重新启动应用程序?