【问题标题】:Trouble debugging Maven integration test in Eclipse在 Eclipse 中调试 Maven 集成测试时遇到问题
【发布时间】:2011-12-15 07:35:23
【问题描述】:

我在 Win XP 上使用 Eclipse Indigo 和 Maven 3.0.3。我创建了一个我希望在 Eclipse 中调试的 Selenium 2 测试。它设置为在 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 集成测试进行逐步调试?

【问题讨论】:

    标签: eclipse maven-2 maven selenium


    【解决方案1】:

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

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

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

    编辑:更新链接

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-07
      • 2010-11-19
      • 1970-01-01
      • 1970-01-01
      • 2017-09-04
      • 1970-01-01
      相关资源
      最近更新 更多