Trying to run ANT JUnit target in debug mode in Eclipse

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

Here is my ANT JUnit target


    

        

        
2条回答
  •  北恋
    北恋 (楼主)
    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:

    
    

    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.

提交回复
热议问题