测试驱动开发(TTD)

阅读: 评论:0

测试驱动开发(TTD)

测试驱动开发(TTD)


        测试应用有很多方法,例如,黑盒测试、白盒测试、迭代测试等,然而,这些方法都是从宏观上描述测试的。为了在技术上保障测试的效果,Kent Beck(也是极限编程创始人)提出了在结果上进行限制的测试方法,也就是在编写程序之前,先确定程序中的变量、控件等元素允许的值。如果在编写程序时,变量、控件中的值与事先确定的值不相符,就说明程序的某处有bug,这种测试方法就是TDD(Test Driver Development,测试驱动开发)。TDD和Opengl ES一样,并不是具体的软件或程序库,只是一套测试框架(Junit),可用于对Android应用程序进行TDD测试。

Android SDK提供的测试框架,该测试框架基于Junit。测试框架不仅可以测试普通的java类(继承AndroidTestcase),也可以测试Android的应用程序组建,如Activity(ActivityInstrumentationTestCase2<>)、ContentProvider(ProviderTestCase<>)、和Service(ServiceTestCase<>)。

The testing framework has these key features:

  1. Android test suites are based on JUnit. You can use plain JUnit to test a class that doesn't call the Android API, or Android's JUnit extensions to test Android components. If you're new to Android testing, you can start with general-purpose test case classes such as AndroidTestCase and then go on to use more sophisticated classes.                                                                                          
  2. The Android JUnit extensions provide component-specific test case classes. These classes provide helper methods for creating mock objects and methods that help you control the lifecycle of a component.          
  3. Test suites are contained in test packages that are similar to main application packages, so you don't need to learn a new set of tools or techniques for designing and building tests.                            
  4. The SDK tools for building and tests are available in Eclipse with ADT, and also in command-line form for use with other IDEs. These tools get information from the project of the application under test and use this information to automatically create the build files, manifest file, and directory structure for the test package.                                                                                             
  5. The SDK also provides monkeyrunner, an API for testing devices with Python programs, and UI/Application Exerciser Monkey, a command-line tool for stress-testing UIs by sending pseudo-random events to a device.


Android测试框架结构图
----------------------------------------------- 真正对的那个人永远不会错过- ---------------------------------------------------
ANDROID 测试类书写指导

测试类型继承的类获取测试对象的代码
ActivityActivityInstrumenttationactivity = Activity()
ContentProviderProviderTestCase2contentProvider = getProvider()
ServiceServiceTestCaseIntent intent = new Intent(mContext,MyService.class);
StartService(intent);
service = getService();
普通Java类AndroidTestCasemyClass = new MyClass();


本文发布于:2024-02-03 04:16:14,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170690497348588.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:测试   TTD
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23