views:

597

answers:

2

I am trying to debug a junit test in eclipse but my breakpoints are not firing (unless they are on the first or second line).

I've tried deleting and recreating all breakpoints in the workspace, cleaning the project, creating a new debug configuration, and running the test method individually and as part of a test class with other methods. But all to no avail :-(

 public void testLoadPatientsAndConvertToBeans() throws IOException, CDataGridException {
  File file = fileutil.getFileFromPrefsOrPrompt(basefileDef);

  CDataBuilder builder = new CDataDelimitedFileBuilder(file, 
    CDataDelimitedFileBuilder.DelimiterSettings.WINDOWS_CSV,
    basefileDef);

  // breakpoints placed on lines from here on do not fire

  CDataCacheContainer container = 
   cacheIO.construct(
     new CDataNarrower(
       cacheIO.construct(builder)
     ).setConvertMissing(true));

  assertEquals(13548, container.size());

  cacheIO.export(container, patients);

  Collection<Patient> pBeans = patients.getBeans();

  assertEquals(container.size(), pBeans.size());

  Patient patient = pBeans.iterator().next();
  Map props = patient.getPropertyMap();

  System.out.println(props);
 }
A: 

My first intuition is that the cached class in eclipse is out of sync with your codes. However, given you have tried clean/rebuild your project, it should have fixed it. As you can put a breakpoint on the 1st/2nd line, what happens when you step through the codes? Does the code align with each steps? If not, it shows that the eclipse has a different version of class from your source codes. If they are the same, I would try to down a newer copy of eclipse (I assumed you have already tried restart your eclipse) since you may have discovered a strange bug (new version may have fixed it or clean some stale data). Sorry that I can't be any more helpful.

Oscar Chan
The code does step through and aligns. Thanks Oscar.
tukushan
+3  A: 

This is likely if you are using Sun JDK 6 Update 14. See another similar SO question here. The likely resolution in such a case is to use Sun JDK 6 Update 16.

Vineet Reynolds
Upgrading to Sun JRE 6 Update 16 did the trick. Thanks Vineet.
tukushan
Unfortunately I'm getting "Vote too old to be changed, unless the answer is edited" and can't upvote this. Can you edit and then I will?
tukushan
+1, @tukushan you should be able to vote for it now if you haven't already
Rich Seller
@Rich, thanks for the edit.
Vineet Reynolds