views:

2617

answers:

3

I am trying to trouble shoot a JUnit. In the source code, I have set break point in two places: 1) in a line where a static member is initialized 2) the first line of one of the test cases.

The debugger stops in the static field initializing line. But it doesn't stop in the test case. No matter where I set the break point in the test case, the debugger doesn't stop there. I know for sure that the test case is executed as I can see the log messages that I have added appear in the log.

Any help would be greatly appreciated.

I am using Eclipse Galileo and JUnit4 launcher.

+1  A: 

Is your code compiled with the -g option turned on to generate the debug information in the .class file? That's required, of course.

duffymo
Yes it is compiled with -g option.
Roy
+6  A: 

This could be related to one of the bugs in JDK 6 Update 14, as indicated in the release notes for JDK 6 update 15.

If this indeed turns out to be the issue, you should move to a higher version of the JDK (that's no guarantee though, since fixes have been released against 6u16, 6u18 and 7b1). The best bet is to use -XX:+UseParallelGC flag. Increasing the size of the minimum and maximum heap size, to delay the first GC, bring temporary relief.

By the way, use this bug report in Eclipse to track how others have been faring.

Vineet Reynolds
I upgraded to JDK 1.6 update 16. Now it stops at all the break points that I have set. Thanks a lot for your help.
Roy
You're welcome. u16 seems to be the release where this was fixed to a good enough extent, despite u15's release notes.
Vineet Reynolds
Thanks @Vineet - I was pulling my hair out over this one :-)
Jim Garrison
+1  A: 

Usually when this happens to me (rare but it does) means that the code being executed is different than the code in the editor. It will happen from time to time for Eclipse that the built classes and the code in editor are out of sync. When that happens I get all sort of weird debugger behavior (debugging empty lines, skipping lines of codes etc).

Restarting Eclipse, clean all projects and rebuild everything usually clears things up. I had also the Maven plugins (older versions... had not had it for a while now) that had a tendency to do that too.

Otherwise it might be a bug, maybe the one Vineet stated,

Hope this helps

Newtopian
Yea, what you've stated happens more in IDEs that do not automatically recompile code. Oracle JDeveloper (from personal experience) and to a lesser extent (Netbeans) have been found wanting.
Vineet Reynolds