首页> 外文期刊>Empirical Software Engineering >Mock objects for testing java systems: Why and how developers use them, and how they evolve
【24h】

Mock objects for testing java systems: Why and how developers use them, and how they evolve

机译:用于测试Java Systems的模拟对象:为什么和开发人员如何使用它们,以及它们如何发展

获取原文
获取原文并翻译 | 示例
           

摘要

When testing software artifacts that have several dependencies, one has the possibility of either instantiating these dependencies or using mock objects to simulate the dependencies' expected behavior. Even though recent quantitative studies showed that mock objects are widely used both in open source and proprietary projects, scientific knowledge is still lacking on how and why practitioners use mocks. An empirical understanding of the situations where developers have (and have not) been applying mocks, as well as the impact of such decisions in terms of coupling and software evolution can be used to help practitioners adapt and improve their future usage. To this aim, we study the usage of mock objects in three OSS projects and one industrial system. More specifically, we manually analyze more than 2,000 mock usages. We then discuss our findings with developers from these systems, and identify practices, rationales, and challenges. These results are supported by a structured survey with more than 100 professionals. Finally, we manually analyze how the usage of mock objects in test code evolve over time as well as the impact of their usage on the coupling between test and production code. Our study reveals that the usage of mocks is highly dependent on the responsibility and the architectural concern of the class. Developers report to frequently mock dependencies that make testing difficult (e.g., infrastructure-related dependencies) and to not mock classes that encapsulate domain concepts/rules of the system. Among the key challenges, developers report that maintaining the behavior of the mock compatible with the behavior of original class is hard and that mocking increases the coupling between the test and the production code. Their perceptions are confirmed by our data, as we observed that mocks mostly exist since the very first version of the test class, and that they tend to stay there for its whole lifetime, and that changes in production code often force the test code to also change.
机译:当测试具有若干依赖项的软件工件时,有可能实例化这些依赖项或使用模拟对象来模拟依赖关系的预期行为。尽管最近的定量研究表明,在开源和专有项目中广泛使用模拟物体,但科学知识仍然缺乏从业者使用模拟的方式和为何。对开发人员(并且没有)在耦合和软件演变方面的影响以及这些决定的影响的实证理解可用于帮助从业者适应和改善他们的未来使用情况。为此目的,我们研究三个OSS项目和一个工业系统中模拟对象的使用。更具体地说,我们手动分析了2000多个模拟的用途。然后,我们与来自这些系统的开发人员讨论我们的调查结果,并识别实践,理由和挑战。这些结果由拥有100多名专业人员的结构化调查支持。最后,我们手动分析了测试代码中模拟对象的使用情况如何随着时间的推移而发展,以及它们对测试和生产代码之间耦合的影响。我们的研究表明,模仿的使用非常依赖上课的责任和架构问题。开发人员报告频繁模拟依赖性,使测试困难(例如,基础架构相关的依赖项)和不是封装系统域概念/规则的模拟类。在关键挑战中,开发人员报告说,维持与原始类别的行为兼容的模拟的行为很难,并且嘲笑增加了测试和生产代码之间的耦合。我们的数据确认了他们的识别,因为我们观察到自最初的测试类自第一个版本以来大多数存在,并且他们倾向于在整个寿命中留下,并且生产代码的变化经常强制测试代码改变。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号