使用 Ant 构建项目并运行 JUnit Test Android 应用程序但 Ant Junit Test 失败 [英] Using Ant to build project and run JUnit Test Android app but Ant Junit Test fails

查看:33
本文介绍了使用 Ant 构建项目并运行 JUnit Test Android 应用程序但 Ant Junit Test 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的 Android 项目.我还为该项目创建了 Junit 案例.我的 Android 应用程序和 TestCases 在同一个项目中.我的结构如下:

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

我更改了订单和导出选项,并确保 JUnit 位于顶部.
我已添加

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" />

在 Eclipse 中运行 Android JUnit 测试工作正常,但是当我尝试构建 &Junit 使用 Ant 测试应用程序构建的项目/应用程序,但测试失败.

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.

错误如下:

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

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

无法弄清楚为什么它在 Ant 中失败.

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

推荐答案

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

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

这篇关于使用 Ant 构建项目并运行 JUnit Test Android 应用程序但 Ant Junit Test 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆