Android的JUnit4测试 [英] Android JUnit4 testing

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

问题描述

我要运行一些JUnit4测试。在code依赖于某些Android库(Android的XML解析器),但不会产生任何活性及等。当我尝试运行测试,我得到了一个Android类,我需要没有被发现。有没有办法运行了Android code JUnit4测试,而不是用一些图书馆测试活动,但测试code。

I want to run some JUnit4 tests. The code relies on some Android libraries(Android XML parser), but does not create any activites and so on. When I try to run tests I got that an Android class that I need was not found. Is there any way to run JUnit4 tests with Android code, not to test activity but to test code with some libraries.

推荐答案

有没有办法(据我所知)的使用JUnit4在Android上。它不支持JUnit3不过,如果这是一个选项,供您?

There is no way (that I'm aware of) to use JUnit4 on Android. It does support JUnit3 though, if that's an option for you?

另外,你可以使用 Robolectric 并在开发机器上运行测试(在那里你会能够使用你最喜欢的单元测试框架)。这是否会为你工作,取决于你在测试什么,但它可能是值得一去?

Alternatively, you could use Robolectric and run your tests on your development machine (where you'll be able to use whichever unit test framework you like). Whether this will work for you depends on exactly what you're testing, but it might be worth a go?

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

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