zoukankan      html  css  js  c++  java
  • Intrumentation类:ActivityInstrumentationTestCase2学习(1)

    public abstract class

    ActivityInstrumentationTestCase2

    extends ActivityTestCase//继承自ActivityTestCase

    This class provides functional testing of a single activity. The activity under test will be created using the system infrastructure (by calling InstrumentationTestCase.launchActivity()) and you will then be able to manipulate your Activity directly.

    -----------------------------------------------------------------------------------------------------------------------------------

    该类提供单独的activity的功能测试.在测试项目下的该activity能够使用系统基类(调用: InstrumentationTestCase.launchActivity())并且你能够直接操作你自己的Activity的。

    • You can run any test method on the UI thread (see UiThreadTest).//你能够在UI thread上跑任何的测试方法
    • You can inject custom Intents into your Activity (see setActivityIntent(Intent)).//你能够在你的Activity注入自定义的Intents(该描述意味着允许跳转)

    This class replaces ActivityInstrumentationTestCase, which is deprecated. New tests should be written using this base class.//该类替代ActivityInstrumentationTestCase, 该类现在不建议使用。新的测试集应该使用该基础类。

    If you prefer an isolated unit test, see ActivityUnitTestCase.//如果你更喜欢一个独立的单元测试,请参见ActivityUnitTestCase

    ------------------------------------------------------------------------------------------------------------------------------------

    Summary:

    Public Constructors:

    ActivityInstrumentationTestCase2(String pkg, Class<T> activityClass)

    //This constructor was deprecated in API level 8. use ActivityInstrumentationTestCase2(Class) instead(在高于API level 8后,该构造方法被下方的方法取代了)

     
    ActivityInstrumentationTestCase2(Class<T> activityClass)
    //Creates an ActivityInstrumentationTestCase2.
    ---------------------------------------------------------------------------------------------------------------------------------------
    Public Methods:
    T getActivity()
    Get the Activity under test, starting it if necessary.//获取在测试下的Activity,如果必要的话可以启动
    void setActivityInitialTouchMode(boolean initialTouchMode)
    Call this method before the first call to getActivity() to set the initial touch mode for the Activity under test.//在第一次调用 getActivity()方法前可以调用该方法去初始化测试下Activity的TOUCH模式
    void setActivityIntent(Intent i)
    Call this method before the first call to getActivity() to inject a customized Intent into the Activity under test.//在第一次调用 getActivity()方法前可以调用该方法去注入测试下Activity的自定义的INTENT
     
     
     
    Protected Methods
    void runTest()
    Runs the current unit test.
    void setUp()
    Sets up the fixture, for example, open a network connection.
    void tearDown()
    Make sure all resources are cleaned up and garbage collected before moving on to the next test.
     
  • 相关阅读:
    为什么写技术博客对新人如此重要?
    Javascript经典正则表达式
    关于读书的那些事,其实我一直...没有行动
    dede织梦CMS文件夹目录结构
    jQ初体验,^_^
    vi/vim 基本使用方法
    (X)HTML Strict 下的嵌套规则
    KISS保持简单:纪念丹尼斯·里奇
    关于jQuery性能优化
    编码规范CSSHTML 摘自kissyui
  • 原文地址:https://www.cnblogs.com/TestingOn/p/3956677.html
Copyright © 2011-2022 走看看