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

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

问题描述

我正在基于Android Bitmap类(称为AndroindLib)编写一个Android Library Project,该项目仅包含实用工具类(无活动).我尝试使用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天全站免登陆