在Eclipse中的JUnit测试上调试断点不起作用

时间:2022-04-17 11:16:28

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).

我试图在日食中调试junit测试,但是我的断点没有触发(除非它们在第一行或第二行)。

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);
 }

2 个解决方案

#1


7  

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.

如果您使用的是Sun JDK 6 Update 14,则可能会出现这种情况。请参阅此处另一个类似的SO问题。在这种情况下,可能的解决方案是使用Sun JDK 6 Update 16。

#2


0  

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.

我的第一个直觉是eclipse中的缓存类与你的代码不同步。但是,鉴于您已尝试清理/重建项目,它应该已修复它。由于您可以在第1行/第2行放置断点,当您单步执行代码时会发生什么?代码是否与每个步骤一致?如果没有,则表明eclipse与源代码具有不同版本的类。如果它们是相同的,我会尝试删除更新的eclipse副本(我假设你已经尝试重启你的eclipse),因为你可能已经发现了一个奇怪的错误(新版本可能已修复它或清理一些陈旧的数据)。对不起,我不能再有帮助了。

#1


7  

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.

如果您使用的是Sun JDK 6 Update 14,则可能会出现这种情况。请参阅此处另一个类似的SO问题。在这种情况下,可能的解决方案是使用Sun JDK 6 Update 16。

#2


0  

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.

我的第一个直觉是eclipse中的缓存类与你的代码不同步。但是,鉴于您已尝试清理/重建项目,它应该已修复它。由于您可以在第1行/第2行放置断点,当您单步执行代码时会发生什么?代码是否与每个步骤一致?如果没有,则表明eclipse与源代码具有不同版本的类。如果它们是相同的,我会尝试删除更新的eclipse副本(我假设你已经尝试重启你的eclipse),因为你可能已经发现了一个奇怪的错误(新版本可能已修复它或清理一些陈旧的数据)。对不起,我不能再有帮助了。