Automatically extracting mock object behavior from Design by Contract#8482; specification for test data generation
Automatically extracting mock object behavior from Design by Contract#8482; specification for test data generation
复制标题
自动从契约设计中提取模拟对象行为
DOI:
--
复制
发表时间:
2010
期刊:
影响因子:
--
通讯作者:
F. Wotawa
中科院分区:
文献类型:
--
作者:
Stefan J. Galler;Andreas Maller;F. Wotawa
Test data generation is an important task in the process of automated unit test generation. Random and heuristic approaches are well known for test input data generation. Unfortunately, in the presence of complex pre-conditions especially in the case of non-primitive data types those approaches often fail. A promising technique for generating an object that exactly satisfies a given pre-condition is mocking, i.e., replacing the concrete implementation with an implementation only considering the necessary behavior for a specific test case. In this paper we follow this technique and present an approach for automatically deriving the behavior of mock objects from given Design by Contract#8482; specifications. The generated mock objects behave according to the Design by Contract#8482; specification of the original class. Furthermore, we make sure that the observed behavior of the mock object satisfies the pre-condition of the method under test. We evaluate the approach using the Java implementations of 20 common Design Patterns and a stack based calculator. Our approach clearly outperforms pure random data generation in terms of line coverage.