How to break into debugger within a jUnit test case?

一笑奈何 提交于 2020-02-04 03:08:51

问题


I'm debugging a unit test in a large java project. I need to run 'ant test ...' to launch the test suite. So it's difficult for me to launch it from the IDE. Is it possible to call some function like Debugger.Break() in C# to break into the debugger if it's attached to any debugger?


回答1:


If I am understanding your question correctly, you can use java's remote debugging by setting these 2 jvm parameters:

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1044

And for debugging your ant task you can add the these parameters in your ant <java> task. For details you may follow java debug options in ant link.



来源:https://stackoverflow.com/questions/12596235/how-to-break-into-debugger-within-a-junit-test-case

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