问题
I'm having trouble debugging my jbehave tests. I cannot get maven to start the jbehave tests and stop at a breakpoint. I have this in my pom:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<version>2.0.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<executions>
<execution>
<id>run-scenarios-found</id>
<phase>test</phase>
<configuration>
<scenarioIncludes>
<scenarioInclude>**/scenario/**/*${test}.java</scenarioInclude>
</scenarioIncludes>
<scenarioExcludes>
<scenarioExclude>**/*Steps.java</scenarioExclude>
</scenarioExcludes>
</configuration>
<goals>
<goal>run-scenarios</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
and I have tried things like:
$ mvn -e -o -Dtest=MyTest -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8787 -Xnoagent -Djava.compiler=NONE" clean test
and
$ export MVN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8787 -Xnoagent -Djava.compiler=NONE" ; mvn -Dtest=MyTest clean test
I can try to use jsadebugd, but I that will probably require immaculate timing to automate, so that sounds like a suboptimal solution, and I feel like the JBehave Maven plugin should provide this functionality. Clearly I have just not found the right piece of documetation yet. Any ideas how I go about this ?
回答1:
The following worked for me: export MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8787 -Xnoagent -Djava.compiler=NONE"
then start my mvn tests: mvn install
(maven now hangs waiting for the debugger to connect)
Then start Eclipse in a remote debug session, pointing at local host, port 8787 (as above), with appropriate breakpoints set.
回答2:
Wouldn't it be easier not to start the tests with maven, but rather in the IDE with JUnit? Then you can use the debugger directly? I normally do it so, that the CI server uses maven to execute JBehave, but in the IDE, I prefer a more direct way of execution.
回答3:
This worked for me:
- In Eclipse Run -> Debug Configurations...
- Select Maven Build and click New button
- Set the goals (
clean very
in my case) and possible parameters - Hit Debug button
回答4:
mvn -e -o -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8787 -Xnoagent -Djava.compiler=NONE" integration-test
This line worked perfect for me. Setup your Jbehave project in eclipse with the debug port (8787) and connect to the debugger quickly while mvn is waiting to connect to your eclipse project.
来源:https://stackoverflow.com/questions/731023/debugging-jbehave-scenarios