如何在Eclipse中配置JUnit的Source

如何在Eclipse中配置JUnit的Source

本文介绍了如何在Eclipse中配置JUnit的Source?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用,我想配置当我尝试浏览其方法时,JUnit向我显示源代码。我尝试将源附加到JUnit库,但库定义不可编辑。我无法找到在首选项中配置JUnit库的位置。



当我打开Add Library窗口并选择JUnit时,我看到一个对话框,我可以在其中选择JUnit版本,但它显示源位置是未找到。



如何配置Eclipse以查找JUnit的源?

解决方案

我下载了Eclipse SDK并检查了差异,我终于找到了。


  1. 下载插入到您的 eclipse / plugins 目录中。


  2. eclipse / configuration / org.eclipse.equinox.source 目录中编辑文件 source.info 并添加以下行:


  3. 打开文件 artifacts.xml code> eclipse 目录,并添加以下片段:

     < artifact classifier = 'osgi.bundle'id ='org.junit4.source'version ='4.5.0.v20090423'> 
    < properties size ='2'>
    < property name ='artifact.size'value ='128389'/>
    < property name ='download.size'value ='128389'/>
    < / properties>
    < / artifact>


  4. 如果Eclipse已经打开,则需要重新启动它才能使更改为检测到


注意对于Eclipse 3.6(Helios),您应该使用更新JAR(S)。注意:在Eclipse 3.6(Helios)上,步骤3(artifacts.xml)不是必需的。

在Ubuntu Eclipse 3.6上测试:

版本:Helios Service Release 2

Build id:20110218-0911


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?

解决方案

I downloaded the Eclipse SDK and checked the differences, and I finally got it to work.

  1. Download this JAR into your eclipse/plugins directory.

  2. Edit the file source.info in your eclipse/configuration/org.eclipse.equinox.source directory, and add the following line:

  3. Open the file artifacts.xml in your eclipse directory, and add the following fragment:

    <artifact classifier='osgi.bundle' id='org.junit4.source' version='4.5.0.v20090423'>
      <properties size='2'>
        <property name='artifact.size' value='128389'/>
        <property name='download.size' value='128389'/>
      </properties>
    </artifact>
    

  4. 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中配置JUnit的Source?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 01:34