无法在Eclipse中调试Maven集成测试

时间:2011-10-25 21:26:19

标签: eclipse maven-2 maven selenium

我在Win XP上使用Eclipse Indigo,使用Maven 3.0.3。我已经创建了一个Selenium 2测试,我希望在Eclipse中进行调试。它设置为在Maven集成测试阶段运行。我正在使用Maven Cargo插件和Tomcat作为容器。这是我的pom.xml中的相关部分......

        <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>8080</cargo.servlet.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:8080/${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>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <!-- Skip the normal tests, we'll run them in the integration-test phase -->
                <skip>true</skip>
            </configuration>
            <executions>
                <execution>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <skip>false</skip>
                    </configuration>
                </execution>
            </executions>
        </plugin>

问题是,当我在Eclipse中右键单击我的集成测试时,选择“Debug As”然后选择我的调试配置(这只是maven目标“clean install -Dtest = TableIntegrationTest”),执行运行时没有点击我设置的断点(http://screencast.com/t/at0AKWwxslE)。如何在Eclipse中的JUnit / Selenium集成测试中进行逐步调试?

1 个答案:

答案 0 :(得分:16)

默认情况下,Maven的集成测试在分叉的JVM中运行。因此,eclipse无法附加到分叉的JVM并看到断点。

您可以使用-DforkMode = never选项强制集成测试在同一JVM中运行。

更多信息:http://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html

修改:更新了链接