简体   繁体   English

使用Ant构建项目并运行JUnit Test Android应用程序,但Ant Junit Test失败

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

I have a simple Android project that I created. 我有一个我创建的简单Android项目。 I also created Junit cases for the project. 我还为该项目创建了Junit案例。 I have my Android app and TestCases in the same project. 我在同一个项目中安装了我的Android应用程序和TestCases。 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. 我已经更改了Order和export选项,并确保JUnit位于顶部。
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. 运行Android JUnit Test在Eclipse中运行良好,但是当我尝试使用Ant构建&Junit测试应用程序时,项目/应用程序构建但测试失败。

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. 无法弄清楚为什么它在Ant中失败了。

最好的方法是通过Export创建自动ant构建,然后选择Ant BuildFiles,然后根据您的要求进行修改。

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

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