Font Size: a A A

Research And Application On MOCK Technique Of Automatic Unit Testing

Posted on:2012-12-17Degree:MasterType:Thesis
Country:ChinaCandidate:C J YinFull Text:PDF
GTID:2218330368995053Subject:Computer technology
Abstract/Summary:PDF Full Text Request
Research on software testing method is an important branch in software engineering. Software testing is the key of software quality ensurance,amounting to 40% or more of the total software development effort is spent on software testing. Automated testing can not only greatly lessen the workload of the tester, but also reduce errors in testing process. And improve testing efficiency is an important way to ensure the quality of software, shorten the development cycle and reduce software engineering investment.The most basic, minimal granularity of testing is unit tests in the testing process. Firstly the paper explores the current prevalent automated unit testing framework in the field, which is difficult to construct test code for complex software, only used for some simple unit tests. Then Tim Mackinnon proposed Mock Object, to simulate the tested object. Mock Object is used to simulate the target object to cut the dependency of the real object. However, besides object oriented functions, there a large amount of process oriented functions, such as traditional C functions, and 3rd party C librariy functions.. These functions do not have the corresponding simulation technology yet。The paper studies the Gmock under existing Mock, analyzes the Mock's shortages leading to the limitations in simulation (Gmock can only mock object's virtual functions), introduces Hook on the basis of current technology, and proposes SuperMock based on Hook. Supermock is designed as three modules, namely, user interfaces, engine and the kernel, which can not only simulate the virtual and non-virtual function of objects, also solve the simulation issues of process oriented functions, such as user C function, and third-party C library functions. Also this paper offers the framework design process of Supermock, which is verified by sample analysis, and finally shows the process of SuperMock's integration with GooGtest, the existing automated unit testing framework, and verifies the unit testing efficiency improving after integrate SUperMock with Googletest.Unlike ordinary Mock Framework, the traditional Mock Framework bases on object which can only simulate virtual function of the object, but Supermock has changed the traditional design of the framework,by locating the target function memory address, hooking it and re-routing to mock function, saving the original instruction before mocking and restoring after mocked. SuperMock makes up for the traditional Mock frameworks lacking of being unable to fully cover, enabling the unit testing on the Mock technologies provide a comprehensive coverage to arbitrary functions. SuperMock extended the implementation of the concept of Mock, enriching and improving unit test theory, which greatly improves the independence of unit testing o...
Keywords/Search Tags:unit test, automating tests, hooks, Mock
PDF Full Text Request
Related items