gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:39:55 27 4
gpt4 key购买 nike

我的代码中有一个 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com