2

我的项目由一个 EJB 模块和一个 Web 模块组成。

EJB 模块使用带有 Persistence 扩展的 Arquillian 来运行集成测试。Arquillian 启动托管的 Jboss7,设置数据库,运行测试,然后关闭 Jboss。我已将 JaCoCo Maven 插件配置为为这些测试生成代码覆盖率报告,并且一切正常 - 报告已创建并导出到声纳服务器。

Web 模块使用带有 Drone/Graphene 扩展的 Arquillian 来运行 Selenium 测试。因此,在我的 CI 构建期间,Arquillian 启动了 Jboss7,启动了 firefox 并自动运行 Selenium 测试套件。这是我遇到麻烦的地方......所有测试都运行得很好,但是没有为此模块生成 JaCoCo 报告。

两个模块共享一个共同的根 pom,这里是这个 pom 的相关位:

<project
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <properties>
        <version.joda.time>2.1</version.joda.time>
        <version.junit>4.11</version.junit>
        <version.mockito>1.9.5</version.mockito>
        <version.jacoco>0.6.0.201210061924</version.jacoco>
        <version.arquillian.jacoco>1.0.0.Alpha5</version.arquillian.jacoco>
        <version.arquillian.persistence>1.0.0.Alpha6</version.arquillian.persistence>
        <version.commons.collections>3.2.1</version.commons.collections>
        <version.guava.testlib>14.0.1</version.guava.testlib>
    </properties>

    <dependencies>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>${version.joda.time}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${version.junit}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>${version.mockito}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava-testlib</artifactId>
            <version>${version.guava.testlib}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>${version.commons.collections}</version>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian.extension</groupId>
                <artifactId>arquillian-drone-bom</artifactId>
                <version>1.2.0.Alpha2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.arquillian</groupId>
                <artifactId>arquillian-bom</artifactId>
                <version>1.0.4.Final</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${version.jacoco}</version>
                <executions>
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>pre-integration-test</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <destFile>target/jacoco-it.exec</destFile>
                            <propertyName>failsafe.argLine</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>post-integration-test</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <dataFile>target/jacoco-it.exec</dataFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.14</version>
                <configuration>
                    <argLine>${failsafe.argLine}</argLine>
                    <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>verify</id>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-jgitflow-plugin</artifactId>
                <version>1.0-alpha14</version>
                <configuration>
                    <enableFeatureVersions>true</enableFeatureVersions>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <pushReleases>true</pushReleases>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>arquillian-jbossas-managed</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack</id>
                                <phase>process-test-classes</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.jboss.as</groupId>
                                            <artifactId>jboss-as-dist</artifactId>
                                            <version>7.1.1.Final</version>
                                            <type>zip</type>
                                            <overWrite>false</overWrite>
                                            <outputDirectory>target</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
                <pluginManagement>
                    <plugins>
                        <!-- Ignore/Execute plugin execution -->
                        <plugin>
                            <groupId>org.eclipse.m2e</groupId>
                            <artifactId>lifecycle-mapping</artifactId>
                            <version>1.0.0</version>
                            <configuration>
                                <lifecycleMappingMetadata>
                                    <pluginExecutions>
                                        <!-- copy-dependency plugin -->
                                        <pluginExecution>
                                            <pluginExecutionFilter>
                                                <groupId>org.apache.maven.plugins</groupId>
                                                <artifactId>maven-dependency-plugin</artifactId>
                                                <versionRange>[1.0.0,)</versionRange>
                                                <goals>
                                                    <goal>unpack</goal>
                                                </goals>
                                            </pluginExecutionFilter>
                                            <action>
                                                <execute />
                                            </action>
                                        </pluginExecution>
                                    </pluginExecutions>
                                </lifecycleMappingMetadata>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
                <testResources>
                    <testResource>
                        <directory>src/test/resources</directory>
                    </testResource>
                </testResources>
            </build>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.as</groupId>
                    <artifactId>jboss-as-arquillian-container-managed</artifactId>
                    <version>7.1.1.Final</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.jboss.arquillian.protocol</groupId>
                    <artifactId>arquillian-protocol-servlet</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.jboss.arquillian.extension</groupId>
                    <artifactId>arquillian-jacoco</artifactId>
                    <scope>test</scope>
                    <version>${version.arquillian.jacoco}</version>
                </dependency>
                <dependency>
                    <groupId>org.jacoco</groupId>
                    <artifactId>org.jacoco.core</artifactId>
                    <version>${version.jacoco}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.jboss.arquillian.junit</groupId>
                    <artifactId>arquillian-junit-container</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.jboss.arquillian.junit</groupId>
                    <artifactId>arquillian-junit-container</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.jboss.arquillian.extension</groupId>
                    <artifactId>arquillian-persistence-impl</artifactId>
                    <version>${version.arquillian.persistence}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>

</project>
4

0 回答 0