开发者

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

开发者 https://www.devze.com 2023-01-08 00:11 出处:网络
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.

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.

here is how my build.xml looks like:

<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}"开发者_JAVA技巧 />
        <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.

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

I haven't reviewed that myself, yet but I believe you can re-use it.

0

精彩评论

暂无评论...
验证码 换一张
取 消