Debug TestNg java code in eclipse that uses Ant

别来无恙 提交于 2020-01-06 03:15:24

问题


I am trying to debug a project in Eclipse(Mars) that does test automation using TestNg and Apache Ant for build. With the available solutions, I am able to debug ant build.xml file, but breakpoints inside java code are not hitting. Can anyone please help me with this on how to debug java source files, especially the test cases in my case in eclipse?

Thanks.


回答1:


I have similar problem, may be it is TestNG bug. But all breakpoints are halting execution if I'm starting not single test (with right-click menu, for example), but starting all Test Suite with *.xml suite-file.




回答2:


I figured the solution to this problem. Follow the following steps to solve this
1. Add following lines inside the task in build.xml file.

<jvmarg value="-Xdebug" />
<jvmarg value="-Xnoagent"/> 
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5432" />
  1. Add remote java application debug configuration, i.e., specify project name, give host as "localhost", and port same as in step 1, 5432 in our case
  2. Debug the build.xml file first
  3. Attach the testng process, by start debugging the remote java application debug configuration set in step 2.


来源:https://stackoverflow.com/questions/37001802/debug-testng-java-code-in-eclipse-that-uses-ant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!