问题
I am trying to debug a JUnit test case within a Maven project in Eclipse on my local machine and I am getting a "Source not found" error on my own test class. I went through all the other similar threads that I could find about the problem, but to the best of my understanding none of them addresses exactly my same problem, nor a solution for it. So here is the detail of what I have done:
- Created a run configuration with the goals "-Dmaven.surefire.debug -Dtest=MyTestClass test"
- Created a remote Java application that connects to localhost:5005. Added the base folder for the project in the "Source" tab.
- Setup a breakpoint in MyTestMethod in MyTestClass. MyTestMethod has the @Test tag.
- Run the run configuration in 1. The application stops listening on port 5005.
- Debug the remote Java application in 2. The debugger window pops up and I see the thread with the stack trace of the classes where things are stopped. The debugger is stopped at the breakpoint that I setup. I can see the variables in this class and in other classes as well, but I get "Source not found" for MyTestClass. If I do "Edit source lookup path", my project is there as I added it in 2.
I am not sure what I am doing wrong. As an alternative, I have also tried to create another run configuration with -DforkMode=never. But if I try to debug that, I get the following error:
ERROR context.TestContextManager: Caught exception while allowing TestExecutionListener
[org.springframework.test.context.support.DependencyInjectionTestExecutionListener@2a46b75b]
to prepare test instance [MyTestClass@8afcd0c]
Thanks.
来源:https://stackoverflow.com/questions/20106495/eclipse-maven-debug-source-not-found