Out of the box cuke4duke offers three main ways to execute: Ant, Maven or cuke4duke-commandline.
But all of those three approaches are a bit tricky if you want to debug your application when executing in a BDD scenario.
There is some information on the wiki how to achieve it.
Here some more details:
Maven and Remote Debugging
When using Maven, you can add the following lines to your cuke4duke config in your pom.xml:
<plugin>
<groupId>cuke4duke</groupId>
<artifactId>cuke4duke-maven-plugin</artifactId>
<configuration>
<jvmArgs>
<jvmArg>-Dcuke4duke.objectFactory=cuke4duke.internal.jvmclass.PicoFactory</jvmArg>
<jvmArg>-Xdebug</jvmArg>
<jvmArg>-Xnoagent</jvmArg>
<jvmArg>-Djava.compiler=NONE</jvmArg>
<jvmArg>-Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y</jvmArg>
</jvmArgs>
(a running example is here)
When you now run the integration-test phase (ie.
mvn verify
), then Maven breaks and waits for a debugger to connect:
[INFO] [cuke4duke:cucumber {execution: run-features}]
[INFO] Listening for transport dt_socket at address: 4000
Now you can connect with Eclipse with a new debug configuration (Run->Debug Configurations...). Choose 'Remote Java Application' and configure the same port as you configured in the pom.xml under address: Now execute this debug configuration, and Maven (which is still waiting) will continue after Eclipse successfully connected, and any breakpoints you set in Eclipse will trigger.
Running from the IDE
Another way is to execute the whole enchilada (JRuby, cuke4nuke, cucumber…) directly out of the IDE. In Eclipse this is accomplished with a new Debug Configuration. Choose Java Application then configure it accordingly: Main class:
org.jruby.Main
Program Arguments:
${M2_HOME}/repository/.jruby/bin/cuke4duke ./target/test-classes features
VM Arguments:
-Dcuke4duke.objectFactory=cuke4duke.internal.jvmclass.PicoFactory
Thanks Jonas,
ReplyDeleteI've added a link to this blog post from the wiki.
Thanks for this post. It was a huge help for me.
ReplyDeleteThanks! got this up and running in no time using the remote java debugger. Nice and easy to use.
ReplyDeleteI'm having a heck of a time trying to get the debugging to work for a basic cuke4duke example. I explain in detail here: http://groups.google.com/group/cukes/browse_thread/thread/4c0bb425cf78a9b4
ReplyDeleteAny help would be greatly appreciated.
HAs anyone really managed to make the in-process debugging work?
ReplyDeleteFollowing a vanilla install I am still finding this impossible - thinking now that my choice of this product was a mistake - debugging and other convenient IDE integration is essential.
Luckily only written a couple of stories with this.
Please help as this seems otherwise like a good product.