Maven为每个IntegrationTest启动容器

时间:2018-03-11 03:44:01

标签: maven containers integration-testing wildfly jboss-arquillian

我使用"嵌入"设置Arquillian wildfly(它在技术上没有嵌入,整个wildfly发行版将被解压缩到目标文件夹并用作托管容器),到目前为止一切运行良好。但是,当我使用maven运行我的整个测试套件时,它会为每个Integrationtest启动容器。有没有办法告诉maven只启动wildfly一次并使用该容器实例进行所有集成测试? 这是我的pom文件和arquillian.xml的摘录

的pom.xml:

<profile>
  <id>wildfly-managed</id>
  <activation>
    <activeByDefault>true</activeByDefault>
</activation>
<!-- dependencies for Wildfly  -->
<dependencies>
    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-arquillian-container-managed</artifactId>
        <version>8.2.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-embedded</artifactId>
        <version>8.2.0.Final</version>
    </dependency>
</dependencies>

<build>
    <testResources>
        <testResource>
            <directory>src/test/resources</directory>
        </testResource>
        <testResource>
            <directory>src/test/resources/META-INF</directory>
        </testResource>
    </testResources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.8</version>
            <executions>
                <execution>
                    <id>unpack</id>
                    <phase>process-test-classes</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.wildfly</groupId>
                                <artifactId>wildfly-dist</artifactId>
                                <version>${version.wildfly}</version>
                                <type>zip</type>
                                <overWrite>false</overWrite>
                                <outputDirectory>target</outputDirectory>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.18.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                    <configuration>
                        <systemPropertyVariables>
                            <arquillian.launch>wildfly-managed</arquillian.launch>
                            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                            <jboss.home>${project.basedir}/target/wildfly-8.2.0.Final</jboss.home>
                            <module.path>${project.basedir}/target/wildfly-8.2.0.Final/modules</module.path>
                        </systemPropertyVariables>
                        <redirectTestOutputToFile>false</redirectTestOutputToFile>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <dependencies>
                <dependency>
                    <groupId>org.junit.platform</groupId>
                    <artifactId>junit-platform-surefire-provider</artifactId>
                    <version>1.0.1</version>
                </dependency>
                <dependency>
                    <groupId>org.junit.jupiter</groupId>
                    <artifactId>junit-jupiter-engine</artifactId>
                    <version>5.0.1</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

arquillian.xml:     

<container qualifier="wildfly-managed" default="true">
    <configuration>
        <property name="jbossHome">${jboss.home}</property>
        <property name="outputToConsole">true</property>
        <property name="allowConnectingToRunningServer">true</property>
        <property name="javaVmArguments">-Xmx1024m -XX:MaxPermSize=512m -Xnoagent -Djava.compiler=NONE -Xdebug
            -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787
        </property>
    </configuration>
</container>

0 个答案:

没有答案