简体   繁体   English

从Android项目中的build.xml生成Junit测试结果

[英]Generate Junit test results from a build.xml in a android project

I am trying to run and publish my JUnit tests in HTML using a build.xml file calling the JUnit target but it doesn't seem to work. 我正在尝试使用调用JUnit目标的build.xml文件以HTML格式运行和发布JUnit测试,但它似乎无法正常工作。

here is how my build.xml looks like: 这是我的build.xml的样子:

<target name="Unity Agent SDK Test ">
    <mkdir dir="${junit.output.dir}" />
    <echo message="making directory" />
    <junit fork="yes" printsummary="yes">
        <formatter type="xml" />
        <test name="com.kc.AllTests" todir="${junit.output.dir}" />
        <test name="com.kc.unity.agent.util.ActivityOneTestcase" todir="${junit.output.dir}" />
        <test name="com.kc.unity.agent.util.FaceBookRestManagerTestCase" todir="${junit.output.dir}" />
        <test name="com.kc.unity.agent.util.OAuthManagerTestCase" todir="${junit.output.dir}" />

        <classpath refid="Unity Agent SDK Test.classpath" />

        <bootclasspath>
            <path refid="run.Unity Agent SDK Test (1).bootclasspath" />
        </bootclasspath>
    </junit>
    <echo message="junit finished" />
</target>
<target name="junitreport">
    <junitreport todir="${junit.output.dir}">
        <fileset dir="${junit.output.dir}">
            <include name="TEST-*.xml" />
        </fileset>
        <report format="frames" todir="${junit.output.dir}" />
    </junitreport>
</target>

Here is the error I get: 这是我得到的错误:

Unity Agent SDK Test :
     [echo] making directory
    [junit] Exception in thread "main" java.lang.RuntimeException: Stub!
    [junit]  at junit.framework.TestResult.<init>(TestResult.java:4)
    [junit]  at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:315)
    [junit]  at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:911)
    [junit]  at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:768)

BUILD FAILED
C:\xxxxxxxxx\Android\Projects\Unity Agent SDK Test\build.xml:85: java.lang.RuntimeException: Stub!

Total time: 1 second

In android you have to run test cases with android instrumentation (adb shell am instrument ...) they cannot be run with junit launcher which is done by ant task. 在android中,您必须使用android工具来运行测试用例(adb shell am instrument ...),它们无法与由ant任务完成的junit启动器一起运行。

Please take a look at http://code.neenbedankt.com/android-junit-results-in-hudson 请查看http://code.neenbedankt.com/android-junit-results-in-hudson

I haven't reviewed that myself, yet but I believe you can re-use it. 我自己尚未对此进行审查,但我相信您可以重复使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM