How to debug cuke4duke using ant and attaching a remote debugger
Following the cuke4duke ant tutorial at http://cuke4ninja.com/sec_ant.html, it supplies the following to run the cuke4duke task:
<taskdef name="cucumber" classname="cuke4duke.ant.CucumberTask" classpathref="compile.classpath"/>
<cucumber args="--verbose开发者_如何学JAVA --require target/test-classes --color --format pretty --format junit --out target/junit-report features" objectFactory="pico">
<classpath>
<pathelement location="target/test-classes"/>
</classpath>
</cucumber>
To debug, according to https://github.com/cucumber/cuke4duke/wiki/Debug-Cuke4Duke-Steps you just add the following jvm arguments:
-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=4000
However, it doesn't actually specify how to do this in ant, and because this isn't a normal java ant task, I have no idea how these arguments are supposed to be added. Does anyone else know? Thanks.
Similar to how findbugs works, apparently you can append the jvm arguments to the cucumber task:
<cucumber args="--verbose --require target/test-classes --color --format pretty --format junit --out target/junit-report features" objectFactory="pico" jvmargs="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=4000">
The cucumber task will break and wait for a remote debugging connection on port 4000, allowing you to debug the code through an IDE such as Eclipse.
精彩评论