Using Ant to build project and run JUnit Test Android app but Ant Junit Test fails

旧时模样 提交于 2019-12-10 17:21:26

问题


I have a simple Android project that I created. I also created Junit cases for the project. I have my Android app and TestCases in the same project. My structure is like the following:

-AndroidApp
    -src
       -SampleActivity
    -tests
       -SampleActivityTest

I have changed the Order and export options and made sure JUnit is at the top.
I have added

<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.sample.app"
android:label="UnitTest" />
<uses-library android:name="android.test.runner" />

Running Android JUnit Test works fine in Eclipse, but when I try to build & Junit Test the app with Ant the project/app builds but the test fails.

Here's the error:

test-run:
       [junit] Test com.mark.prototype.test.SampleAndroidAppTest FAILED

compile-and-test:
BUILD SUCCESSFUL
Total time: 3 seconds

Can't figure out why it's failing in Ant.


回答1:


Best way is create auto ant build via Export then select Ant BuildFiles and then modify it according to your requirement.



来源:https://stackoverflow.com/questions/10355363/using-ant-to-build-project-and-run-junit-test-android-app-but-ant-junit-test-fai

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!