android - Android/Ant 的自动化单元测试

标签 android testing ant junit

我的代码中有一个 Android 项目和 JUnit 测试。

我想知道是否有ant 任务 来运行一些测试。

事实上,我有几个使用 JUnit 运行的经典测试来测试几种方法,还有一些测试需要 android 模拟器或者至少需要在 android 设备上运行。

因为我没有找到任何文档,所以我想知道是否可以做那种事情。

喜欢

junit-android dir="."...

非常感谢您的帮助和时间。

只是说清楚,因为我在网上搜索并没有找到很多东西,所以希望你能帮忙。

我有一个不包含任何 Activity 的 Android 项目。

实际build.xml文件:

  1. 我编译java源代码
  2. 它为我生成一个 .jar 文件。
  3. 我需要运行我的project/tests/ 文件夹中定义的一些测试,使用 之前生成的库。这些测试需要在 使用 ANT 构建文件的仿真器设备,不依赖于 eclipse 。

项目:

  • src (java source code)
  • gen
  • bin
  • res
  • tests (Android test project)
  • AndroidManifest.xml
  • build.xml
  • ...

生成的测试项目包含一个使用 android 更新命令 自动生成的 build.xml。可悲的是,没有任务“运行测试”。我如何指定我想将我的库用于这些测试?

最佳答案

从命令行创建和运行 android 测试项目所需的一切,由 Google 自己提供;-) http://developer.android.com/tools/testing/testing_otheride.html

command line你需要的是这样的:

adb shell am instrument -w <test_package_name>/<runner_class>

要从 Ant 调用它,请使用 <run-tests/>任务,描述 here.

关于android - Android/Ant 的自动化单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14123317/

相关文章:

Android:开始使用相机和图片上传/联网

android - 细蓝色进度条

java - Ant : moving a file into a target directory

ant - 如何避免在未更改的源文件上运行 ant 任务?

html - 引用其他资源的 Android HTML 资源

android - 通过 ADB 在 android 广播中将 JSON 作为额外数据发送时格式不正确

python - Python 中的一切测试的外行非先决介绍 Material 在哪里?

testing - 对于 OSGi(集成)测试,Arquillian 与 Pax Exam 相比如何?

在 groovy 中测试私有(private)方法

Ant 属性文件条目未解析为其值