Providing developer-approved descriptive names for unit tests

Date
2023
Journal Title
Journal ISSN
Volume Title
Publisher
University of Delaware
Abstract
Unit tests are a critical artifact that supports the software development process in several major ways. For example, when a test fails, its name can provide the first step towards comprehending the purpose of the test and fix the potential bug or issue found in software. As an alternative to reading tens or hundreds of lines of code, comprehension of unit tests is the foundation towards modifying existing tests, adding new tests, or removing unnecessary tests. Therefore, having a descriptive name that can summarize the purpose and context of the test is the key to a successful fix towards the potential bug or issue. Unfortunately, unit tests often lack descriptive names, and non-descriptive names prevent developers from accomplishing the first step of unit testing, comprehension of unit tests. ☐ This dissertation presents a novel method for generating descriptive names for unit tests. This method is based on test patterns and the uniqueness of the test to parse the test body and extract the purpose and context of the test to generate a descriptive name for the test. These combine as a natural and intuitive way to learn the information embedded in the test and use it to produce a descriptive name. Existing work tried to solve the naming problem of unit test. However, existing approaches, either fixing current names or generating new names to replace current names, ignored the vastly existing naming rationales that are commonly used by developers. Therefore, their fixed or generated names often failed to meet developers’ approval. Conversely, our method is mainly based on quantitative and empirical studies, which highly focused on the need of developers. ☐ The first contribution of this dissertation is a pattern-based approach to detect non- descriptive test names and provide initial guidance to fix them. After these non-descriptive names are detected and the initial clue about how to fix them is acquired, the next step is to extract the uniqueness of the test as a middle step towards generating descriptive names. The second contribution of this dissertation is to automatically identify the uniqueness of the test. This step laid the foundation of our name generation approach, which was conducted in an independent, empirical study. After the uniqueness of the test is identified, we can further use it to generate descriptive name. Finally, based on the uniqueness of the test, the last contribution is the name generation approach, which can provide descriptive test names that meet developers’ needs.
Description
Keywords
Software testing, Static analysis, Unit test
Citation