简体   繁体   中英

Debug TestNg java code in eclipse that uses Ant

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.

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.

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, ie, 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM