Trying to run ANT JUnit target in debug mode in Eclipse

前端 未结 2 1812
离开以前
离开以前 2021-02-04 11:49

Here is my ANT JUnit target


    

        

        
相关标签:
2条回答
  • 2021-02-04 12:28

    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.

    0 讨论(0)
  • 2021-02-04 12:30

    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 explains this in detail. For you, only the last part right before "Conclusion" is important.

    0 讨论(0)
提交回复
热议问题