如何在 Eclipse 中配置 JUnit 的源代码?
我正在使用 Eclipse Galileo for Java EE,并且我想配置 JUnit 以显示当我尝试导航到它的方法时,我会看到源代码。 我尝试将源附加到 JUnit 库,但库定义不可编辑。 我什至无法在首选项中找到配置 JUnit 库的位置。
当我打开“添加库”窗口并选择 JUnit 时,我会看到一个对话框,可以在其中选择 JUnit 版本,但它显示“未找到源位置”。
如何配置 Eclipse 来查找 JUnit 的源代码?
I am using Eclipse Galileo for Java EE, and I want to configure JUnit to show me the source code when I try to navigate to its methods. I've tried attaching source to the JUnit library, but the library definition is not editable. I cannot even find where to configure the JUnit library in the preferences.
When I open the Add Library window and choose JUnit, I see a dialog where I can choose the JUnit version, but it shows that Source Location is "not found".
How can I configure Eclipse to find JUnit's source?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我下载了Eclipse SDK并检查了差异,终于让它工作了。
下载将此 JAR 放入您的
eclipse/plugins
目录中。编辑
eclipse/configuration/org.eclipse.equinox.source
目录中的文件source.info
,并添加以下行:<块引用>
org.junit4.source,4.5.0.v20090423,plugins/org.junit4.source_4.5.0.v20090423.jar,-1,false
在您的
中打开文件
目录,并添加以下片段:artifacts.xml
>eclipse如果 Eclipse 已打开,则需要重新启动它才能进行更改被检测到。
注意:对于 Eclipse 3.6 (Helios),您应该使用更新的 JAR。 请参阅@Supressingfire 和@Milo 的评论。
注意:在 Eclipse 3.6(Helios) 上,步骤 3 (artifacts.xml) 不是必需的。
在 Ubuntu Eclipse 3.6 上测试:
版本:Helios 服务版本 2
内部版本号:20110218-0911
I downloaded the Eclipse SDK and checked the differences, and I finally got it to work.
Download this JAR into your
eclipse/plugins
directory.Edit the file
source.info
in youreclipse/configuration/org.eclipse.equinox.source
directory, and add the following line:Open the file
artifacts.xml
in youreclipse
directory, and add the following fragment:If Eclipse is already open, you'll need to restart it for the changes to be detected.
Note: For Eclipse 3.6 (Helios), you should use the updated JAR(s). See the comments by @Supressingfire and @Milo.
Note: on Eclipse 3.6(Helios), step 3 (artifacts.xml) is not necessary.
Tested on Ubuntu Eclipse 3.6:
Version: Helios Service Release 2
Build id: 20110218-0911
我的eclipse版本是4.6.0,到目前为止对我有用的唯一解决方案是从 ftp://ftp.osuosl.org/pub/eclipse/eclipse/updates/4.6/R -4.6-201606061100/plugins/,然后放入eclipse\plugins,重启eclipse后源文件就自动绑定到合适的junit jar文件了。
My eclipse version is 4.6.0, the only solution that has worked so far for me is to download the source file which named org.junit.source_4.12.0.v201504281640.jar from ftp://ftp.osuosl.org/pub/eclipse/eclipse/updates/4.6/R-4.6-201606061100/plugins/, then placed it into eclipse\plugins, afterwards restart eclipse then the source file has bound to the appropiate junit jar file automatically.
如此线程中所述,如果您已下载Galileo 的 SDK 版本,您拥有主要插件的源代码。
对于 JUnit,这将是:
您可以尝试将其添加为 JUnit 启动器配置的“源”选项卡中的源文件,并查看在调试 JUnit 测试并单步执行 JUnit 本机方法时是否可以解决您的问题。
(注意:我有 x64 版本的 eclipse Galileo,但我相信 x32 或其他平台的文件是相同的)
As mentioned in this thread, if you have downloaded the SDK version of Galileo, you have the sources of the main plugins.
For JUnit, this would be:
You can try to add that as a source file in the Source tab of a JUnit launcher configuration and see if that solves your issue when you are debugging your JUnit test and are stepping through JUnit native methods.
(Note: I have the x64 version of eclipse Galileo, but I believe the file is the same for the x32 or for other platforms)
@Hosam Aly 答案也适用于 Eclipse 4.3.1:
eclipse\configuration\org.eclipse.equinox.source
的文本是org.junit.source,4.11.0.v201303080030,plugins/org.junit.source_4.11.0.v201303080030.jar,-1,false
artifacts.xml< /代码>
@Hosam Aly answer also works in Eclipse 4.3.1:
eclipse\configuration\org.eclipse.equinox.source
isorg.junit.source,4.11.0.v201303080030,plugins/org.junit.source_4.11.0.v201303080030.jar,-1,false
artifacts.xml