我可以使用断言在Android设备上? [英] Can I use assert on Android devices?

查看:136
本文介绍了我可以使用断言在Android设备上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用在我的Andr​​oid应用断言关键字摧毁在某些情况下,在模拟器上,或在测试我的设备我的应用程序。这可能吗?

I want to use the assert keyword in my android apps to destroy my app in some cases on the emulator, or my device during testing. Is this possible?

看来这个模拟器根本不理我的断言。

It seems that the emulator just ignores my asserts.

推荐答案

该API提供了 JUnit的断言

您可以做

import static junit.framework.Assert.*;

现在你可以使用像assertTrue,assertEquals有,assertNull在JUnit框架提供的所有功能。

now you can use all the functions like assertTrue, assertEquals, assertNull that are provided in the junit framework.

要小心,不要通过月食导入Junit4框架,这将是org.junit包。你必须使用junit.framework包得到它的工作在Android设备或仿真器上。

Be careful not to import the Junit4 framework through eclipse, that would be the org.junit package. You have to use the junit.framework package to get it working on an android device or the emulator.

这篇关于我可以使用断言在Android设备上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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