问题
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