Question: Here is my ANT JUnit target

```
<target name="test" depends="compile" >
    <junit failureProperty="test.failure" >

        <jvmarg value="-Xdebug" />
        <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5432" />

        <classpath>
            <pathelement path="${basedir}\..\Core\lib\junit-4.10.jar"/>
            <pathelement path="${basedir}\..\Suggestion\lib\ssce.jar"/>
            <pathelement path="C:\Java\javamail-1.4.1\mail.jar"/>
            <pathelement path="C:\Java\commons-net-2.0\commons-net-ftp-2.0.jar"/>
            <pathelement path="${basedir}\WebContent\WEB-INF\lib\gson-2.2.1.jar"/>
            <pathelement path="${tomcatLibs}\servlet-api.jar"/>
        </classpath>
        <classpath>
            <pathelement path="${build}"/>
        </classpath>
        <formatter type="brief" usefile="false" />          
        <test name="com.server.junit.ServerTestSuite" />
        <test name="com.junit.DictionaryTestSuite" />   
        <test name="com.util.junit.SuggestionTestSuite" />              
    </junit>

    <fail message="Unit test failed" if="test.failure"/>
</target>

```

My unit tests pass fine if run through Eclipse but fail if I laund them from ANT.
I want it to stop at my break point in a Unit test. 
From documentation I know I need to add these jvmarg but can't get it to stop so I obviously don't have them in the right place.
Also, I don't think I have the port correct but what port should I use? I didn't have to set up any debug port when debugging JUnits through eclipse, it just worked

Answer: 
You need to forget a moment that you can run JUnit tests and ANT targets from within Eclipse. What you want is to debug a Java application that happens to have the main class `org.apache.tools.ant.Main` and which can be started with `ant` from the command line.

You have now two options: You can create a launch config that invokes `org.apache.tools.ant.Main` but that's pretty complicated to set up (you will have to replicate everything that the `ant` script does at startup).

The other alternative is to configure `ant` correctly. In your case, the tests run within the `ant` process but I know no simple way to pass `-Xdebug` to Ant itself. Therefore, you must run the tests in a new process. Add this to the `junit` task:

```
<junit fork="yes" forkmode="once" ...>

```

Without this, `jvmarg` parameters will be ignored.

The next step is to create a debug configuration in Eclipse. [This article](http://www.ibm.com/developerworks/java/library/os-eclipse-javadebug/index.html) explains this in detail. For you, only the last part right before "Conclusion" is important.
Detailed instructions:

1. In Eclipse, navigate to Run | Debug.
2. Select Remote Java Application, on the left column. Click New, on the bottom of the same column.
3. In the Create configuration screen you'll be prompted to enter some values. Start with a meaningful name. For Project, select the Java project that contains the source code you want to debug. Leave Connection Type in default, i.e. Standard (Socket Attach) . For Host , enter localhost. If you want to debug a remote server, enter its hostname or IP address. For port, enter 5432.
4. Click Apply.
5. Make sure your tests is running in debug mode. In the same screen click Debug . Eclipse should automatically take you to the Debug perspective and you should see a stack trace in the Debug view.
6. If you are not automatically taken to the Debug perspective, select Window | Open Perspective | Other and then click Debug.

Taken from [here](http://www.eclipsezone.com/eclipse/forums/t53459.html).