在Android上使用mockito加速编译
我目前正在 eclipse 中开发一个 android 应用程序,使用:
- 一个应用程序项目
- 一个测试项目(Instrumentation 和 Pojo 测试)
在测试项目中,我导入了用于标准 POJO 测试的 mockito 库。 然而,当我导入库时,Eclipse 中的编译时间从 1 秒飙升至约 30 秒。原因似乎是每次都转换整个库。所以基本上,每次进行我想要测试的修改时,我都必须等待 30 秒。
到目前为止,我发现的唯一解决方法是:
- 禁用“自动构建”
- 创建一个仅包含 pojo 测试的项目并仅将mockito 放在那里。
- 使用另一个编译速度更快的库(例如easymock)
还有其他建议吗?
I am currently developing an android app in eclipse using:
- One project for the app
- One project for the tests (Instrumentation and Pojo tests)
In the test project, I am importing the mockito library for standard POJO testing.
However, when I import the library, the compilation time skyrockets from 1 second to about 30 seconds in eclipse. The cause seems to be that the whole library is converted each time. So basically, each time a make a modification that I want to test, I have to wait 30 seconds.
The only workarounds that I have found so far would be:
- Disable "Build Automatically"
- Create a project that includes only pojo tests and put mockito only there.
- Use another library that compiles faster (e.g. easymock)
Any other suggestion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你需要测试项目是android项目吗?
如果可以了解创建一个 Java 项目并模拟任何 Android 特定类以进行测试,这将是我的建议。
看看这篇文章:
https://sites.google.com/site/androiddevtesting/
Do you need the test project to be an android project?
If can get aware with creating a Java project and mocking out any of the android specific classes for the tests that would be my suggestion.
Have a look at this article:
https://sites.google.com/site/androiddevtesting/