Understanding and Characterizing Mock Assertions in Unit Tests
Hengcheng Zhu, Valerio Terragni, Lili Wei, Shing-Chi Cheung, Jiarong Wu, Yepang Liu
摘要
Mock assertions provide developers with a powerful means to validate program behaviors that are unobservable to test assertions. Despite their significance, they are rarely considered by automated test generation techniques. Effective generation of mock assertions requires understanding how they are used in practice. Although previous studies highlighted the importance of mock assertions, none provide insight into their usages. To bridge this gap, we conducted the first empirical study on mock assertions, examining their adoption, the characteristics of the verified method invocations, and their effectiveness in fault detection. Our analysis of 4,652 test cases from 11 popular Java projects reveals that mock assertions are mostly applied to validating specific kinds of method calls, such as those interacting with external resources and those reflecting whether a certain code path was traversed in systems under test. Additionally, we find that mock assertions complement traditional test assertions by ensuring the desired side effects have been produced, validating control flow logic, and checking internal computation results. Our findings contribute to a better understanding of mock assertion usages and provide a foundation for future related research such as automated test generation that support mock assertions.
CCS Concepts: • Software and its engineering → Software testing and debugging; • General and reference → Empirical studies.
问问这篇 Paper
智能体会读完全文。
Lune 把这篇 Paper 索引到了每一个公式,引用它的顶会 Paper 也一样。你提问,回答直接引用原文。
引用它的顶会 Paper1
问问它们各自怎么用它它引用的顶会 Paper3
- Use of Test Doubles in Android Testing: An In-Depth InvestigationMattia Fazzini, Chase Choi, Juan Manuel Copia, Gabriel Lee 等ICSE 2022 · 被引用 19 次
- MockSniffer: Characterizing and Recommending Mocking Decisions for Unit TestsHengcheng Zhu, Lili Wei, Ming Wen, Yepang Liu 等ASE 2020 · 被引用 17 次
- An automatic refactoring framework for replacing test-production inheritance by mocking mechanismXiao Wang, Lu Xiao, Tingting Yu, Anne Woepse 等FSE 2021 · 被引用 15 次
相关 Paper
- Measuring and Mitigating Gaps in Structural TestingSoneya Binta Hossain, Matthew B. Dwyer, Sebastian G. Elbaum, Anh Nguyen-TuongICSE 2023 · 被引用 7 次
- Studying Test Annotation Maintenance in the WildDong Jae Kim, Nikolaos Tsantalis, Tse-Hsun Peter Chen, Jinqiu YangICSE 2021 · 被引用 20 次
- An Empirical Study of Suppressed Static Analysis WarningsHuimin Hu, Yingying Wang, Julia Rubin, Michael PradelFSE 2025 · 被引用 1 次
- Virtual Reality (VR) Automated Testing in the Wild: A Case Study on Unity-Based VR ApplicationsDhia Elhaq Rzig, Nafees Iqbal, Isabella Attisano, Xue Qin 等ISSTA 2023 · 被引用 20 次
- Test Automation in Open-Source Android Apps: A Large-Scale Empirical StudyJun-Wei Lin, Navid Salehnamadi, Sam MalekASE 2020 · 被引用 27 次
