Automatic mock object creation for test factoring

Download: PDF, PostScript.

“Automatic mock object creation for test factoring” by David Saff and Michael D. Ernst. In ACM SIGPLAN/SIGSOFT Workshop on Program Analysis for Software Tools and Engineering (PASTE'04), (Washington, DC, USA), June 7-8, 2004, pp. 49-51.
A summary appeared as “Test factoring: Focusing test suites on the test at hand” by David Saff. In ICSE'05, Proceedings of the 27th International Conference on Software Engineering, (St. Louis, MO, USA), May 18-20, 2005.


Test factoring creates fast, focused unit tests from slow system-wide tests; each new unit test exercises only a subset of the functionality exercised by the system tests. Augmenting a test suite with factored unit tests, and prioritizing the tests, should catch errors earlier in a test run.

One way to factor a test is to introduce mock objects. If a test exercises a component A, which is designed to issue queries against or mutate another component B, the implementation of B can be replaced by a mock. The mock has two purposes: it checks that A's calls to B are as expected, and it simulates B's behavior in response. Given a system test for A and B, and a record of A's and B's behavior when the system test is run, we would like to automatically generate unit tests for A in which B is mocked. The factored tests can isolate bugs in A from bugs in B and, if B is slow or expensive, improve test performance or cost.

This paper motivates test factoring with an illustrative example, proposes a simple procedure for automatically generating mock objects for factored tests, and gives examples of how the procedure can be extended to larger change languages.

Download: PDF, PostScript.

BibTeX entry:

   author = {David Saff and Michael D. Ernst},
   title = {Automatic mock object creation for test factoring},
   booktitle = {ACM SIGPLAN/SIGSOFT Workshop on Program Analysis for
	Software Tools and Engineering (PASTE'04)},
   pages = {49--51},
   address = {Washington, DC, USA},
   month = {June~7--8,},
   year = {2004}

(This webpage was created with bibtex2web.)

Back to Program Analysis Group publications.