Debug a Junit Ant Task from Eclipse

Sometimes you run into a test that works when run from within Eclipse but not from the command line. To debug the failing test from Eclipse, you can configure the Junit ant task to accept remote debugging sessions.

This can be done by adding the following lines to the junit task:

<junit fork="true">
		<!-- For remote debugging from Eclipse -->
		<jvmarg value="-Xdebug" />
		<jvmarg value="-Xnoagent" />
		<jvmarg value="-Djava.compiler=NONE" />
value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y" />

This will make the task wait for an incoming debug connection on port 8787. It is necessary to have the fork attribute on the junit task set to true, because the jvmarg values can only be given to a starting Java virtual machine.

Getting Debug Output From Scripts on ASPX Pages

To get some useful output when debugging C# or VB scripts on aspx
pages use the following statement in the script:

System.Diagnostics.Debug.WriteLine("We are here!");

In Visual Studio, attach the debugger to the process serving the
page containing the script (typically an IIS server process).
The debug text, “We are here!”, now appears in the output window
whenever the aforementioned statement in the script is executed!