如何测试 Android 库项目 [英] How to test an Android Library Project

查看:18
本文介绍了如何测试 Android 库项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个基于 Android Bitmap 类(称为 AndroindLib)的 Android 库项目,该项目仅包含实用程序类(无活动).我尝试使用 Android JUnit 对其进行测试,但它一直抱怨找不到 AnroidLib.apk

I am writing an Android Library Project basing on Android Bitmap class (call it AndroindLib) which contains only utility class (no activity). I tried to test it using Android JUnit, but it keeps complaining that can't find the AnroidLib.apk

对 Android 库项目进行单元测试的正确方法是什么?

What's the right way to Unit test Android Library Project?

推荐答案

引用 文档:

在库项目中设置代码和资源测试的推荐方法有两种:

"There are two recommended ways of setting up testing on code and resources in a library project:

  • 您可以设置一个测试项目来检测依赖于库项目的应用程序项目.然后,您可以向项目中添加库特定功能的测试.

  • You can set up a test project that instruments an application project that depends on the library project. You can then add tests to the project for library-specific features.

您可以设置依赖于库的标准应用程序项目,并将检测放在该项目中.这使您可以创建一个包含测试/仪器和要测试的代码的自包含项目."

You can set up a standard application project that depends on the library and put the instrumentation in that project. This lets you create a self-contained project that contains both the tests/instrumentations and the code to test."

这篇关于如何测试 Android 库项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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