Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Jenkins中运行Ant的JUnit测试而不访问源文件?_Ant_Junit_Jenkins - Fatal编程技术网

在Jenkins中运行Ant的JUnit测试而不访问源文件?

在Jenkins中运行Ant的JUnit测试而不访问源文件?,ant,junit,jenkins,Ant,Junit,Jenkins,我想让客户能够使用Ant和Jenkins运行JUnit测试。我不想将源文件部署到客户的服务器上 如果客户有一个正在运行的jenkins安装,而我只给他我们编译的Java类、编译的测试类和ant脚本,那么客户是否能够在不访问源代码的情况下使用jenkins执行测试 我的蚂蚁目标看起来像这样 <target name="testWithoutCompile"> <junit fork="true" forkmode="perBatch" haltonerror=

我想让客户能够使用Ant和Jenkins运行JUnit测试。我不想将源文件部署到客户的服务器上

如果客户有一个正在运行的jenkins安装,而我只给他我们编译的Java类、编译的测试类和ant脚本,那么客户是否能够在不访问源代码的情况下使用jenkins执行测试

我的蚂蚁目标看起来像这样

<target name="testWithoutCompile">      
    <junit fork="true" forkmode="perBatch" haltonerror="false" haltonfailure="false" showoutput="false" printsummary="true" clonevm="true">
        <classpath>
            <path refid="test.run.classpath" />
        </classpath>
        <formatter type="xml" />
        <batchtest todir="${report.test.dir}">
            <fileset dir="${build.test.dir}">
                <include name="**/*Test.class" />
            </fileset>
        </batchtest>
    </junit>
</target>

是的,这是可能的,至少直接使用Ant

我在本地有一个简单的项目(只有src和classes子目录),在那里我可以运行一个特定的单元测试,只需使用类文件(我事先删除了测试类源和被测试类的源)


[junit]测试运行:1,失败:0,错误:1,运行时间:0.011秒
[少年]
[junit]Testcase:testNoise(TestHobbyHorse):导致错误
[junit]预期:但是:
[junit]位于TestHobbyHorse.testNoise(未知源)
[少年]

我还没有测试过,但假设您可以扩展它来运行各种测试类,就像您在build.xml中尝试过的那样,而且Jenkins应该只运行Ant一样,我不明白为什么Jenkins的预见性会影响它。

如果您已经有了一个在本地测试它们的环境,那么测试就很简单了,我想你是对的,虽然现在在本地测试对我来说有点复杂,所以我希望有一个通用的答案来帮助我决定是否值得这样做。如果你要向客户发送单元测试类文件,那么为什么不将它们打包成一个单独的jar文件呢?更简单,测试可以进行版本控制,并与测试的代码一起发布。
<target name="test">
        <junit>
              <classpath refid="test.path" />
              <formatter type="brief" usefile="false" />
              <test name="TestHobbyHorse" />
        </junit>
</target>

[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.011 sec
[junit] 
[junit] Testcase: testNoise(TestHobbyHorse):    Caused an ERROR
[junit] expected:<[noSound]> but was:<[Neigh]>
[junit]     at TestHobbyHorse.testNoise(Unknown Source)
[junit]