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
期刊:
International Conference/Workshop on Automation of Software Test
影响因子:
--
通讯作者:
F. Wotawa
F. Wotawa
中科院分区:
--
文献类型:
--
作者:
Stefan J. Galler;Andreas Maller;F. Wotawa

文献摘要

被引文献

相似文献

测试数据的生成是自动化单元测试生成过程中的一项重要任务。随机和启发式方法是众所周知的测试输入数据生成。不幸的是,在复杂的前提条件下,特别是在非原语数据类型的情况下,这些方法往往会失败。一种很有前途的技术可以生成一个完全满足给定前提条件的对象,它是mock,也就是说,用一个只考虑特定测试用例的必要行为的实现代替具体的实现。在本文中,我们遵循这种技术,并提出了一种方法来自动从给定的契约式设计#8482中派生模拟对象的行为;规范。生成的模拟对象的行为遵循契约式设计#8482;原始类的规格说明。此外,我们确保观察到的模拟对象的行为满足被测方法的先决条件。我们使用20种常见设计模式的Java实现和基于堆栈的计算器来评估这种方法。我们的方法在线路覆盖方面明显优于纯随机数据生成。
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.