采用Android测试框架 [英] Using Android Test Framework

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

问题描述

Android提供各种封装测试样

  

AndroidTestCase   ApplicationTestCase   InstrumentationTestCase   ActivityInstrumentationTestCase2 ActivityTestCase

我需要知道如何决定哪个方案最适合测试我的应用程序。一些信息在这个环节提供了

HTTP:<一href="http:////developer.android.com/reference/android/test/package-summary.html">//developer.android.com/reference/android/test/package-summary.html

但我需要更多这方面的清晰...

解决方案

测试用例 - 普通老式的JUnit测试案例。它可以扩展到测试不依赖于Android框架实用工具类。

  

AndroidTestCase - 它扩展了JUnit的TestCase。这是一个打火机   相比于测试类   ActivityTestCase。它并不需要   发起一个活动来运行它。其   的getContext()方法可以让你得到   注入的情况下,如果你需要一个。   因为你可以从这个上下文   类,可以抬高你的UI对象   以测试他们的行为。

ActivityInstrumentationTestCase2 - 这是ActivityInstrumentationTestCase的新版本。 ActivityInstrumentationTestCase是pcated在Android SDK中1.5代$ P $。这是相对于AndroidTestCase较重的测试类。它提供了用户界面和功能测试的单个活动。你可以得到你是通过调用其getActivity()方法测试上注入的活动。该活动被测试启动并完成在每次试验后。<​​/ P>

  

ActivityUnitTestCase - 它给   所测试的活性的分离的   环境。当使用它来测试一个   活性时,不附加   到系统中。这给你更多   在什么样的环境控制   您希望您的活动是   在测试。

ApplicationTestCase - 它提供了测试应用程序类。它可以用来检验一个应用程序的生命周期。

  

InstrumentationTestRunner - 运行Android的测试亚军   案例。

我刚刚发现this..Hope这会有所帮助别人......如果妳希望有更多的像何时以及如何使用的详细信息,请参阅在Android SDK中的样例目录中APIDemos测试应用程序。

Android provides various packages for testing like

AndroidTestCase ApplicationTestCase InstrumentationTestCase ActivityInstrumentationTestCase2 ActivityTestCase

I need to know how to decide which package is best suitable for testing my app. Some info is provided in this link

http://developer.android.com/reference/android/test/package-summary.html

But I need more clarity on this...

解决方案

TestCase – Plain old JUnit test case. It can be extended to test utility classes that are not tied to the Android framework.

AndroidTestCase – It extends JUnit’s TestCase. It’s a lighter testing class compared to ActivityTestCase. It doesn’t need to launch an activity to run it. Its getContext() method allows you to get an injected context if you need one. Since you can get a context from this class, you can inflate your UI objects to test their behaviors.

ActivityInstrumentationTestCase2 – It’s the newer version of ActivityInstrumentationTestCase. ActivityInstrumentationTestCase is deprecated in Android SDK 1.5. It’s a heavier testing class compared to AndroidTestCase. It provides UI and functional testing for a single activity. You can get an injected activity that you are testing on by calling its getActivity() method. The activity being tested is launched and finished before and after each test.

ActivityUnitTestCase – It gives the tested activity an isolated environment. When using it to test an activity, the activity is not attached to the system. This gives you more control over what kind of environment that you want your activity to be tested in.

ApplicationTestCase – It provides testing for Application classes. It can be used to test the life cycle of an application.

InstrumentationTestRunner – The runner that runs the Android test cases.

I just found this..Hope this helps for others...If u want more details like when and how to use, see the APIDemos test application in the samples directory within android SDK.

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

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