An Exploratory Study on the Usage and Readability of Messages Within Assertion Methods of Test Cases

Unit testing is a vital part of the software development process and involves developers writing code to verify or assert production code. Furthermore, to help comprehend the test case and troubleshoot issues, developers have the option to provide a message that explains the reason for the assertion failure. In this exploratory empirical study, we examine the characteristics of assertion messages contained in the test methods in 20 open-source Java systems. Our findings show that while developers rarely utilize the option of supplying a message, those who do, either compose it of only string literals, identifiers, or a combination of both types. Using standard English readability measuring techniques, we observe that a beginner's knowledge of English is required to understand messages containing only identifiers, while a 4th-grade education level is required to understand messages composed of string literals. We also discuss shortcomings with using such readability measuring techniques and common anti-patterns in assert message construction. We envision our results incorporated into code quality tools that appraise the understandability of assertion messages.

[1]  J. Clause,et al.  Automated Identification of Uniqueness in JUnit Tests , 2023, ACM Trans. Softw. Eng. Methodol..

[2]  Vincent J. Hellendoorn,et al.  Test smells 20 years later: detectability, validity, and reliability , 2022, Empirical Software Engineering.

[3]  D. Winkler,et al.  What Do We Know About Readability of Test Code? - A Systematic Mapping Study , 2022, 2022 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER).

[4]  Mohamed Wiem Mkaouer,et al.  An Ensemble Approach for Annotating Source Code Identifiers With Part-of-Speech Tags , 2021, IEEE Transactions on Software Engineering.

[5]  Mohamed Wiem Mkaouer,et al.  Test Smell Detection Tools: A Systematic Mapping Study , 2021, EASE.

[6]  Mohamed Wiem Mkaouer,et al.  Using Grammar Patterns to Interpret Test Method Name Evolution , 2021, 2021 IEEE/ACM 29th International Conference on Program Comprehension (ICPC).

[7]  Mohamed Wiem Mkaouer,et al.  Contextualizing rename decisions using refactorings, commit messages, and data types , 2020, J. Syst. Softw..

[8]  Amna Eleyan,et al.  Enhancing Software Comments Readability Using Flesch Reading Ease Score , 2020, Inf..

[9]  Fernando Castor Filho,et al.  Evaluating Code Readability and Legibility: An Examination of Human-centric Studies , 2020, 2020 IEEE International Conference on Software Maintenance and Evolution (ICSME).

[10]  Mohamed Wiem Mkaouer,et al.  On the Generation, Structure, and Semantics of Grammar Patterns in Source Code Identifiers , 2020, J. Syst. Softw..

[11]  Antonia Bertolino,et al.  JTeC: A Large Collection of Java Test Classes for Test Code Analysis and Processing , 2020, MSR.

[12]  James Clause,et al.  A Pattern-based Approach to Detect and Improve Non-descriptive Test Names , 2020, J. Syst. Softw..

[13]  Ridi Ferdiana,et al.  Test Case Understandability Model , 2020, IEEE Access.

[14]  Mohamed Wiem Mkaouer,et al.  On the distribution of test smells in open source Android applications: an exploratory study , 2019, CASCON.

[15]  Gabriele Bavota,et al.  On the Quality of Identifiers in Test Code , 2019, 2019 19th International Working Conference on Source Code Analysis and Manipulation (SCAM).

[16]  Venera Arnaoudova,et al.  Improving Source Code Readability: Theory and Practice , 2019, 2019 IEEE/ACM 27th International Conference on Program Comprehension (ICPC).

[17]  Mohamed Wiem Mkaouer,et al.  An empirical investigation of how and why developers rename identifiers , 2018, IWoR@ASE.

[18]  Marco Aurélio Gerosa,et al.  Impacts of coding practices on readability , 2018, ICPC.

[19]  Michael Beigl,et al.  Descriptive Compound Identifier Names Improve Source Code Comprehension , 2018, 2018 IEEE/ACM 26th International Conference on Program Comprehension (ICPC).

[20]  Harald C. Gall,et al.  An Empirical Investigation on the Readability of Manual and Generated Test Cases , 2018, 2018 IEEE/ACM 26th International Conference on Program Comprehension (ICPC).

[21]  Michael Hucka,et al.  Spiral: splitters for identifiers in source code files , 2018, J. Open Source Softw..

[22]  Dawn J Lawrie,et al.  The need for software specific natural language techniques , 2018, Empirical Software Engineering.

[23]  Gordon Fraser,et al.  Generating unit tests with descriptive names or: would you name your children thing1 and thing2? , 2017, ISSTA.

[24]  Heejin Jeong,et al.  How Consistent Are the Best-Known Readability Equations in Estimating the Readability of Design Standards? , 2017, IEEE Transactions on Professional Communication.

[25]  Janet Siegmund,et al.  Shorter identifier names take longer to comprehend , 2017, 2017 IEEE 24th International Conference on Software Analysis, Evolution and Reengineering (SANER).

[26]  Burak Turhan,et al.  How Good Are My Tests? , 2017, 2017 IEEE/ACM 8th Workshop on Emerging Trends in Software Metrics (WETSoM).

[27]  Emily Hill,et al.  Towards automatically generating descriptive names for unit tests , 2016, 2016 31st IEEE/ACM International Conference on Automated Software Engineering (ASE).

[28]  Mario Linares Vásquez,et al.  Improving code readability models with textual features , 2016, 2016 IEEE 24th International Conference on Program Comprehension (ICPC).

[29]  Emily Hill,et al.  Automatically Generating Test Templates from Test Names (N) , 2015, 2015 30th IEEE/ACM International Conference on Automated Software Engineering (ASE).

[30]  Gordon Fraser,et al.  Generating Readable Unit Tests for Guava , 2015, SSBSE.

[31]  Gordon Fraser,et al.  Modeling readability to improve unit tests , 2015, ESEC/SIGSOFT FSE.

[32]  Giuliano Antoniol,et al.  Linguistic antipatterns: what they are and how developers perceive them , 2015, Empirical Software Engineering.

[33]  A. D. Lucia,et al.  Are test smells really harmful? An empirical study , 2015, Empirical Software Engineering.

[34]  Wiebke Wagner,et al.  Steven Bird, Ewan Klein and Edward Loper: Natural Language Processing with Python, Analyzing Text with the Natural Language Toolkit , 2010, Lang. Resour. Evaluation.

[35]  Westley Weimer,et al.  Learning a Metric for Code Readability , 2010, IEEE Transactions on Software Engineering.

[36]  René Witte,et al.  Automatic Quality Assessment of Source Code Comments: The JavadocMiner , 2010, NLDB.

[37]  Gerard Meszaros,et al.  xUnit Test Patterns: Refactoring Test Code , 2007 .

[38]  Paul W. Oman,et al.  Development and Application of an Automated Source Code Maintainability Index , 1997, J. Softw. Maintenance Res. Pract..

[39]  Roger S. Pressman,et al.  Software Engineering: A Practitioner's Approach , 1982 .

[40]  M. L. Stein,et al.  How to write plain English , 1975 .

[41]  R. P. Fishburne,et al.  Derivation of New Readability Formulas (Automated Readability Index, Fog Count and Flesch Reading Ease Formula) for Navy Enlisted Personnel , 1975 .

[42]  R. Flesch A new readability yardstick. , 1948, The Journal of applied psychology.