简体   繁体   English

使用自定义Main类为Wildfly Swarm Web应用程序运行Arquillian测试

[英]Running Arquillian tests for a Wildfly Swarm Web application with custom Main class

We have a Web application that is packaged as a WAR file using Wildly Swarm. 我们有一个Web应用程序,使用Wildly Swarm打包为WAR文件。 The Web application is configured via a custom Main class that is processed when starting the swarm application. 通过自定义Main类配置Web应用程序,该类在启动swarm应用程序时将进行处理。

Now we would like to guard our application with Arquillian tests. 现在,我们要使用Arquillian测试来保护我们的应用程序。 How can we configure the ShrinkWrap Archive created in the Arquillian test suite to use our Main class when starting the Web application for testing? 启动Web应用程序进行测试时,我们如何配置在Arquillian测试套件中创建的ShrinkWrap存档以使用Main类?

Use the dependency 使用依赖

<dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>arquillian</artifactId>
</dependency>

This provides the annotation @CreateSwarm which you can use in your arquillian test to create a custom Swarm object, just like you are doing in your main-class. 它提供了@CreateSwarm批注,您可以在@CreateSwarm测试中使用它来创建自定义Swarm对象,就像在主类中一样。

@RunWith(Arquillian.class)
public class SomeTest {
    @Deployment
    public static JavaArchive createTestArchive() { /* ... */ }

    @CreateSwarm
    public static Swarm newContainer() throws Exception {
        Swarm swarm = new Swarm();
        // configure your swarm thingy
        return swarm;
    }

Unfortunately, I have not actually gotten this to work yet. 不幸的是,我实际上还没有开始工作。 Arquillian with Wildfly Swarm is - at time of posting - still considered unstable. 在发布时,带有Wildfly Swarm的Arquillian仍然被认为是不稳定的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM