2

我正在使用 Maven 3.0.3。我想在我的测试阶段运行一些 Junit 测试,在我的集成测试阶段运行其他测试。问题是在集成测试阶段没有运行任何东西。我运行命令

mvn clean install

开始一切。这是我配置我的surefire插件的方式......

        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <skip>false</skip>
                <additionalClasspathElements>
                    <additionalClasspathElement>${project.build.sourceDirectory}</additionalClasspathElement>
                    <additionalClasspathElement>${project.build.testSourceDirectory}</additionalClasspathElement>
                </additionalClasspathElements>
                <useManifestOnlyJar>false</useManifestOnlyJar>
                <forkMode>always</forkMode>
                <systemProperties>
                    <property>
                        <name>gwt.args</name>
                        <value>-out \${webAppDirectory}</value>
                    </property>
                </systemProperties>
                <excludes>
                    <exclude>**/integration/**</exclude>
                </excludes> 
            </configuration>
            <executions>
                <execution>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <skip>false</skip>
                        <includes>
                            <include>**/integration/**</include>
                        </includes> 
                    </configuration>
                </execution>
            </executions>
        </plugin>

我的“集成”目录中有两个 JUnit 测试。我正在使用 Maven Cargo 插件在集成阶段启动服务器。这是配置...

        <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <configuration>
                <container>
                    <containerId>tomcat${tomcat.major}x</containerId>
                    <zipUrlInstaller>
                        <url>http://archive.apache.org/dist/tomcat/tomcat-${tomcat.major}/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.tar.gz</url>
                        <downloadDir>${project.build.directory}/downloads</downloadDir>
                        <extractDir>${project.build.directory}/extracts</extractDir>
                    </zipUrlInstaller>
                    <output>${project.build.directory}/tomcat${tomcat.major}x.log</output>
                    <log>${project.build.directory}/cargo.log</log>
                </container>
                <configuration>
                    <home>${project.build.directory}/tomcat-${tomcat.version}/container</home>
                    <properties>
                        <cargo.logging>high</cargo.logging>
                        <cargo.servlet.port>${tomcat.servlet.port}</cargo.servlet.port>
                        <cargo.tomcat.ajp.port>${tomcat.ajb.port}</cargo.tomcat.ajp.port>
                    </properties>
                </configuration>
            </configuration>
            <executions>
                <execution>
                    <id>start-container</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>start</goal>
                        <goal>deploy</goal>
                    </goals>
                    <configuration>
                        <deployer>
                            <deployables>
                                <deployable>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <type>war</type>
                                    <pingURL>http://localhost:${tomcat.servlet.port}/${project.artifactId}</pingURL>
                                    <pingTimeout>30000</pingTimeout>
                                    <properties>
                                        <context>${project.artifactId}</context>
                                    </properties>
                                </deployable>
                            </deployables>
                        </deployer>
                    </configuration>
                </execution>
                <execution>
                    <id>stop-container</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

任何想法如何更改/增强我的配置以便我的集成测试能够运行?- 戴夫

4

1 回答 1

2

看看Maven 故障安全插件

于 2011-11-28T15:53:58.750 回答