首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我应该将我的单元测试文件夹添加到Eclipse中的java构建路径吗?

我应该将我的单元测试文件夹添加到Eclipse中的java构建路径吗?
EN

Stack Overflow用户
提问于 2013-02-06 21:55:47
回答 2查看 2.1K关注 0票数 3

我们正在开发一个由几个插件组成的Eclipse产品,其中一些插件是由我们开发的。我们的每个插件都被定义为工作区中的一个Eclipse插件项目,并且有两个文件夹,source和test。最近,我注意到我们正在向用户交付测试类,就像我们的源类一样。现在,我想从产品的结果中删除测试类。我应该从Java构建路径(见附件)中删除test文件夹吗?我还应该做些什么来避免将我们的测试部署到最终用户?

为了构建项目,我们使用eclipse标准ant脚本来创建zip文件。我找不到在哪里可以排除测试文件。下面是Ant脚本:

代码语言:javascript
复制
<property name="allElementsFile" value="${eclipse.pdebuild.scripts}/productBuild/allElements.xml"/>
<import file="${eclipse.pdebuild.scripts}/build.xml"/>
<property name="pluginPath" value=""/>
<property name="pluginList" value=""/>
<property name="featureList" value=""/>
<property name="includeLaunchers" value="true"/>
<property name="generatedBuildProperties" value=""/>
<condition property="nestedInclusions" value="true">
    <istrue value="${p2.gathering}" />
</condition>

<!-- ===================================================================== -->
<!-- main entry point to setup, fetch, generate, build etc. Use -->
<!-- the customTargets.xml to modify the build behaviour. -->
<!-- ===================================================================== -->
<target name="main" description="the main build target">    
    <antcall target="preBuild" />
    <antcall target="processRepos"/>
    <antcall target="generateFeature"> <!-- Generate the feature to drive the fetch -->
        <param name="verify" value="false"/>
    </antcall>
    <antcall target="fetch" />
    <antcall target="generateFeature"> <!-- We are calling generate feature a second time so that we can get the pack / unpack clause fixed -->
        <param name="verify" value="true"/>
    </antcall> 
    <antcall target="generate" /> 
    <antcall target="process" /> 
    <antcall target="assemble" />
    <antcall target="package" />
    <antcall target="postBuild" />
</target>

<!-- ===================================================================== -->
<!-- Generate a container feature based on the product file                -->
<!-- The plugin or feature containing the .product file will need to exist -->
<!-- already, use preSetup or postSetup to fetch it if necessary           -->
<!-- ===================================================================== -->
<target name="generateFeature">
    <eclipse.generateFeature
        featureId="org.eclipse.pde.build.container.feature"
        buildDirectory="${buildDirectory}"
        baseLocation="${baseLocation}"
        productFile="${product}"
        verify="${verify}"
        pluginPath="${transformedRepoLocation}${path.separator}${pluginPath}"
        configInfo="${configs}"
        pluginList="${pluginList}"
        featureList="${featureList}"
        includeLaunchers="${includeLaunchers}"
        buildPropertiesFile="${generatedBuildProperties}"
        nestedInclusions="${nestedInclusions}"
        filterP2Base="${filterP2Base}"
    />
</target>


</project>
EN

回答 2

Stack Overflow用户

发布于 2013-02-06 22:29:17

这是您的部署过程/脚本的问题。您是否正在使用Eclipse构建jar?它不应该与构建路径有关,如果您使用Eclipse对它们进行编码,那么您应该将测试源代码放在构建路径中。通常,使用Ant或Maven的部署过程将从结果中排除测试类(jar、war等)。在创建jar之前自动运行测试也是明智的。

票数 1
EN

Stack Overflow用户

发布于 2013-02-08 16:21:48

要在使用pde ant脚本构建pde项目时从代码中删除测试文件(如果您为每个插件项目定义了一个源文件夹和一个测试文件夹),您应该从该项目的build.properties中删除测试文件夹。build.properties是plugin.xml的一部分

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14730824

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档