我的代码中有一个 Android 项目和 JUnit 测试。
我想知道是否有ant 任务 来运行一些测试。
事实上,我有几个使用 JUnit 运行的经典测试来测试几种方法,还有一些测试需要 android 模拟器或者至少需要在 android 设备上运行。
因为我没有找到任何文档,所以我想知道是否可以做那种事情。
喜欢
junit-android dir="."...
非常感谢您的帮助和时间。
只是说清楚,因为我在网上搜索并没有找到很多东西,所以希望你能帮忙。
我有一个不包含任何 Activity 的 Android 项目。
实际build.xml文件:
- 我编译java源代码
- 它为我生成一个 .jar 文件。
- 我需要运行我的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/