Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何运行多个JavaFX测试?_Java_Spring Boot_Testing_Javafx_Junit - Fatal编程技术网

如何运行多个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