调试eclipse单元测试代码“测试类应该只有一个”和“工作区已关闭”错误

时间:2012-12-15 04:22:53

标签: java eclipse unit-testing debugging junit

我正在尝试构建eclipse插件(org.eclipse.jdt.ui.tests.refactoring)。

enter image description here

从git下载源代码,我可以构建项目。 我想调试ExtractMethodTest例程,我只是在setUP例程中设置一个断点,然后启动调试器。

enter image description here

但是,我收到了初始化错误。

enter image description here

然后,我尝试通过右键单击包资源管理器中的ExtractMethodTests.java来启动调试器,以获取Workspace is closed错误。

enter image description here enter image description here 可能有什么问题?我只想启动ExtractMethodTests.java单元测试来逐行跟踪代码。

2 个答案:

答案 0 :(得分:1)

您是否尝试使用错误版本的JUnit运行? Eclipse附带了JUnit 3和Junit 4兼容的运行时。

其次,你的单元测试实际上是否有一个0-arg构造函数?

显然,我没有检查代码库,看看Eclipse人员是否知道如何创建单元测试。我只是假设他们这样做。

答案 1 :(得分:0)

“测试类应该只有一个”错误

使用JUnit 3作为测试运行器解决了第一个问题,但我仍然遇到工作空间问题。我会打开另一篇文章。

enter image description here

“工作区已关闭”错误

Workspace is closed error的提示开始,我将测试作为插件测试来执行。

enter image description here