如何运行多个JavaFX测试?
我必须用如何运行多个JavaFX测试?,java,spring-boot,testing,javafx,junit,Java,Spring Boot,Testing,Javafx,Junit,我必须用JavaFxGUI测试一些Spring应用程序。不幸的是,我不能一个接一个地把它们放在一起。我使用的是java11、junit5.3和TestFX库 我尝试添加如下方法: @Before public void setUp() throws Exception { System.setProperty("spring.profiles.active", "test"); launch(Main.class); } 我认为它
JavaFx
GUI测试一些Spring
应用程序。不幸的是,我不能一个接一个地把它们放在一起。我使用的是java11
、junit5.3
和TestFX
库
我尝试添加如下方法:
@Before
public void setUp() throws Exception
{
System.setProperty("spring.profiles.active", "test");
launch(Main.class);
}
我认为它会重新启动应用程序并正常工作。不幸的是,只有一个测试以正确的方式启动并执行。在其他情况下,我得到错误:
java.util.concurrent.ExecutionException: org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [HikariDataSource (HikariPool-2)] with key 'dataSource'; nested exception is javax.management.InstanceAlreadyExistsException: com.zaxxer.hikari:name=dataSource,type=HikariDataSource
整个测试类现在看起来是这样的:
@Before
public void setUp() throws Exception
{
System.setProperty("spring.profiles.active", "test");
launch(Main.class);
}
@Override
public void start(Stage stage) throws Exception {
stage.show();
}
@Test
public void testRegisterButton()
{
clickOn("#register_button");
}
@Test
public void testLoginButton()
{
sleep(200L);
}
}
这里只有一个简单的测试示例。我以前做的
init()
@Configuration
@EnableAutoConfiguration(exclude = {
JmxAutoConfiguration.class
})
或
spring.jmx.enabled = false