Android单元测试研究与实践(15)

发表于:2017-02-21来源:meituan作者:潘铭炜 黄超点击数: 标签:单元测试Android
} 对控件的点击验证是调用performClick(),然后断言验证其行为。对于ListView这类涉及到Adapter的控件的点击验证,写法如下: //listView被展示之后 listView.perf
 
  • 对控件的点击验证是调用performClick(),然后断言验证其行为。对于ListView这类涉及到Adapter的控件的点击验证,写法如下:

    
    
    1. //listView被展示之后 
    2.  
    3. listView.performItemClick(listView.getAdapter().getView(position, nullnull), 0, 0); 

    与button等控件稍有不同。

    Dialog和Toast测试

    测试Dialog和Toast的方法如下:

    
    
    1. public

      原文转自:http://tech.meituan.com/Android_unit_test.html