ImageVerifierCode 换一换
格式:DOCX , 页数:27 ,大小:63.88KB ,
资源ID:12865207      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-12865207.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Software testing.docx)为本站会员(b****8)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

Software testing.docx

1、Software testingSoftware testing目录1. Specialized Unit Testing 11.1 mock object(模拟对象) 11.2 refactoring(重构) 21.3 Roles(角色定义) 32. JUnit 42.1 What is JUnit 42.2 The features of JUnit 42.3 What is the test case(测试用例) 42.4 Using a test fixture(测试夹具) 52.5 JUnit for single tests 52.6 What is a TestSuite(测试套

2、件) 63. Unit 3 black-box testing 63.1 FUNCTIONAL TESTING(功能测试) 63.2 STRESS TESTING(压力测试) 73.3 LOAD TESTING(负载测试) 73.4 AD-HOC TESTING(随机测试) 73.5 EXPLORATORY TESTING(探索性测试) 83.6 USABILITY TESTING(可用性测试) 84. Unit 4 black-box testing 84.1 FACTS TESTING 84.2 SMOKE TESTING(烟雾测试) 94.3 RECOVERY TESTING(恢复性测试

3、) 94.4 VOLUME TESTING(容量测试) 94.5 DOMAIN TESTING(域测试) 94.6 SCENARIO TESTING(场景测试) 94.7REGRESSION TESTING(回归测试) 104.8 USER ACCEPTANCE TESTING(用户验收测试-测试) 104.9 ALPHA TESTING(测试) 114.10 BETA TESTING(测试) 115. Unit 5 white-box testing 115.1 What is white-box testing 115.2 Advantages and disadvantages of w

4、hite-box testing 115.3 UNIT TESTING(单元测试) 125.4 STATIC & DYNAMIC ANALYSIS(静态动态分析) 135.5 STATEMENT COVERAGE(语句覆盖) 135.6 BRANCH COVERAGE(分支覆盖) 135.7 SECURITY TESTING(安全测试) 135.8 MUTATION TESTING(变异测试) 136. Unit 6 Boundary value analysis and Equivalence partitioning, explained with simple example 136.1

5、 Equivalence Partitioning(等价划分) 146.2 Boundary value analysis(边界值分析) 146.3 Test information flow(测试信息流) 146.4 Loop Testing(循环测试) 156.5 Black box testing tries to find errors in the following categories 157. Testing for Real-Time Systems 167.1 What is Real-time Systems(实时系统) 167.2 Automated Testing T

6、ools(自动化测试工具) 167.3 Criteria for Completion Testing(测试完成标准) 171. Specialized Unit Testing1.1 mock object(模拟对象)1. What is mock objectA mock object is, as the name implies, a simulation of some real object. In Java, a mock object would typically be an implementation, with very limited functionality, o

7、f an Interface. Mock objects play a significant role in unit testing, for a number of reasons.2. Why we make mock objectYoud consider using a mock object for your unit test if the real object has a complex set-up, uses many system resources (like CPU power), or doesnt yet exist! If youre writing an

8、application that uses adatabase, theres no need to wait for the team that develops the database modules before you start coding the rest of the application. What you need is a mock object that behaves like the database modules. If you have interfaces defined to the database modules youre ready to go

9、. Coding with these interfaces might even bring some problems in the Interface design to the surface before the coding of the database modules has even started!Unit testing has become widely accepted as a best practice for software development. When you write an object, you must also provide an auto

10、mated test class containing methods that put the object through its paces, calling its various public methods with various parameters and making sure that the values returned are appropriate.(在编写对象的同时,要提供验证该对象的测试类,该测试类要能够调用该对象的所有公共方法和属性。)When youre dealing with simple data or service objects, writin

11、g unit tests is straightforward. However, many objects rely on other objects or layers of infrastructure. When it comes to testing these objects, it is often expensive, impractical, or inefficient to instantiate(实例化) these collaborators(协作者).For example, to unit test an object that uses a database,

12、it may be burdensome to install, configure, and seed a local copy of the database, run your tests, then tear the local database down again. Mock objects provide a way out of this dilemma.A mock object conforms to the interface of the real object, but has just enough code to fool the tested object an

13、d track its behavior. For example, a database connection for a particular unit test might record the query while always returning the same hardwired result.As long as the class being tested behaves as expected, it wont notice the difference, and the unit test can check that the proper query was emit

14、ted.3. Mock in the middleThe common coding style for testing with mock objects is to: Create instances of mock objects Set state and expectations in the mock objects Invoke domain code with mock objects as parameters Verify consistency in the mock objects1.2 refactoring(重构)Reference: 重构(Refactoring)

15、就是在不改变软件现有功能的基础上,通过调整程序代码改善软件的质量、性能,使其程序的设计模式和架构更趋合理,提高软件的扩展性和维护性.Cleaning up code, perhaps by moving a field from one class to another, pushing some code up or down a hierarchy. Most often it is the process of splitting out repetitive code to turn it into its own separate method.A refactoring is a

16、code change that leaves the original functionality intact(破坏了原来功能的完整性), but changes the design of the code so that its cleaner, more efficient, and easier to test. Refactoring is not always desirable(可取的), nor does it always result in code that is cleaner or easier to understand. In many cases, chan

17、ging the method signature so the collaborator becomes a parameter will result in a confusing, untested snarl of code inside the methods original callers.Problem:The object being tested creates a collaborator object. This collaborator must be replaced with a mock object.(正在被测试的对象创建了一个协作对象,这个协作对象必须被虚拟

18、对象所替换)class Application . public void run() View v = new View(); /创建了一个协作对象,这个对象必须被mock对象所替换 v.display();. Solution:Extract the creation code into a factory method, override this factory method in a test subclass, and then make the overridden method return a mock object instead. Finally, if practica

19、l, add a unit test that requires the original objects factory method to return an object of the correct type:【将创建代码提取到一个工厂方法, 在测试子类覆盖这个工厂方法,然后让重写的方法返回一个mock对象。最后如果可能的话增加一个单元测试让原始对象的工厂方法返回一个对象的正确类型】class Application . public void run() View v = createView(); /将需要创建的mock对象封装到一个方法中 v.display();. protec

20、ted View createView() /重写这个方法,让它返回一个mock对象 return new View(); .class ApplicationTest extends TestCase /增加一个单元测试,让原始对象的工厂方法返回一个对象的正确类型 MockView mockView = new MockView(); public void testApplication Application a = new Application() protected View createView() return mockView; ;a.run(); mockView.vali

21、date(); private class MockView extends View boolean isDisplayed = false; public void display() isDisplayed = true; public void validate() assertTrue(isDisplayed); 1.3 Roles(角色定义)Target object: The object being testedCollaborator object: The object created or obtained by the targetMock object: A subc

22、lass (or implementation) of the collaborator that follows the mock object pattern.Specialization object: A subclass of the target that overrides the creation method to return a mock instead of a collaborator.In your test code, create a mock object implementing the same interface as the collaborator.

23、In your test code, create a specialization object that extends (specializes) the target.In the specialization object, override the creation method to return a mock object that accommodates your test.Optional(可选的): create a unit test to assure that the original target objects factory method still ret

24、urns the correct, non-mock object.2. JUnitJava has an excellent testing suite called JUnit. In order to use this, you will need to have a Java compiler, Ant, and JUnit installed.2.1 What is JUnitJUnit is a simple open source Java testing framework used to write and run repeatable automated tests. It

25、 is an instance(实例) of the xUnit architecture for unit testing framework. Eclipse supports creating test cases and running test suites, so it is easy to use for your Java applications. JUNIT-JUnit是一个简单的开源Java测试框架用来编写和运行重复自动化测试。这是一个作为单元测试框架的xUnit架构的实例。Eclipse支持创建测试用例,运行测试套件,所以它很容易为你的Java应用程序使用。2.2 Th

26、e features of JUnit Assertions for testing expected results(为预期的测试结果申明断言) Test fixtures for sharing common test data(Test fixtures 工具来共享常用的测试数据) Test suites for easily organizing and running tests(测试套件来更容易的组织和运行测试) Graphical and textual test runners(结果图形化、文本化)2.3 What is the test case(测试用例)A test ca

27、se is a class which holds a number of test methods. For example if you want to test some methods of a classBookyou create a classBookTestwhich extends the JUnitTestCaseclass and place your test methods in there.Create a subclass of TestCase:public class BookTest extends TestCase /.Write a test metho

28、d to assert expected results on the object under test, the naming convention for a test method is testXXX()public void testCollection() Collection collection = new ArrayList(); assertTrue(collection.isEmpty();Write asuite()method that uses reflection to dynamically create a test suite containing all

29、 thetestXXX()methods:public static Test suite() return new TestSuite(BookTest.class);2.4 Using a test fixture(测试夹具) A test fixture is useful if you have two or more tests for a common set of objects. Using a test fixture avoids duplicating the test code necessary to initialize and cleanup those comm

30、on objects for each test. 测试夹具是有用的,如果一套共同的对象有两个或更多的测试。使用一个测试夹具避免为每个必须初始化和清理的常见的对象的测试来复制测试代码。To create a test fixture, define asetUp()method that initializes common object and atearDown()method to cleanup those objects.The JUnit framework automatically invokes thesetUp()method before a each test is r

31、un and thetearDown()method after each test is run.public class BookTest2 extends TestCase private Collection collection; protected void setUp() collection = new ArrayList(); protected void tearDown() collection.clear(); public void testEmptyCollection() assertTrue(collection.isEmpty(); 2.5 JUnit for single testsJUnit supports two ways (static and dynamic) of running single tests.1. Static wayIn static way you override therunTest()method inherited(继承) form TestCase class and call the desired test case. A convenient w

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2