简体   繁体   English

如何测试Android库?

[英]How to test an android library?

I am writing an android library project and trying to test it. 我正在编写一个android库项目并尝试对其进行测试。 I found testing a library project more difficult than it has to be using my current method. 我发现测试库项目比使用当前方法要困难得多。

Right now, I am exporting the library project into jar file. 现在,我将库项目导出到jar文件中。 Then I put it into the libs folder of the test project and the test target project. 然后,将其放入测试项目和测试目标项目的libs文件夹中。 Then I add it to build path of both projects and run the test. 然后我将其添加到两个项目的构建路径并运行测试。

Every time I make a change to the library I have to do this again. 每次我对库进行更改时,都必须再次执行此操作。 Is there easier way to do this? 有没有更简单的方法可以做到这一点?

There is some reference to this in the google docs. 谷歌文档中对此有一些参考。 Check out http://developer.android.com/tools/projects/index.html#testing 查看http://developer.android.com/tools/projects/index.html#testing

Basically, the easiest way is to write an application that uses the library project and then add unittests to that application. 基本上,最简单的方法是编写一个使用库项目的应用程序,然后向该应用程序添加单元测试。 When creating the tests via eclipse, you can choose to test modules from within your library project. 通过eclipse创建测试时,可以选择从库项目中测试模块。 This way, changes to the library project are automatically applied. 这样,对库项目的更改将自动应用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM