Skip to content

denivancampos/testsmellspreventionguidelines

Repository files navigation

Welcome 👋

📌 This reade.me shows test smells prevention guidelines. This guide first presents the structures of test codes that can be indicators of the presence of test smells. Secondly, we present the definition of six types of test smells. Third, we present a guideline on how to prevent the insertion of these six test smells in the test code; then, we validate this guideline through an experiment.

📎 Link to paper [not available]

📋 Abstract:Software development is a collaborative and social activity that necessitates the knowledge and expertise of multiple individuals. Software development is more than just coding and programming. It includes many human-centered characteristics, such as communication and personality, which can have a substantial impact on the success of software projects and code quality. Several studies in the literature address the quality of test code and the corrections of test smells and their refactorings. However, little empirical evidence exists on human aspects and test code quality. Our previous works investigated the relationship between developer experience, test creation, and maintenance strategies through developers' perceptions and test code quality. This study aims to create and validate a set of guidelines to prevent the insertion of 6 types of test smells when creating and maintaining test cases during the software evolution. In this sense, we want to derive a set of guidelines based on our previous studies. Based on shared knowledge and developers' experiences, we have created a set of guidelines to help developers avoid inserting test smells when creating unit test classes. The results of this research point to the effectiveness and applicability of the test smell prevention guidelines, showing a positive relationship through high Cronbach's alpha coefficients. In addition, the study reports the importance of considering developers' diverse experiences and perspectives in developing and implementing test guidelines, highlighting that even those familiar with JUnit faced challenges when creating test cases.

JAVA JUNIT testsmell refactoring

SoftwareEngineering Developers'perception Software Maintenance Evolution

Test code

To ensure that the test cases are of the highest quality, it is essential to check whether our test code contains structures that may negatively affect the effectiveness of our tests. The following structures can be harmful to test code and may be indicators of the presence of "test smells".
  • A test method that contains multiple assertion statements without an argument as a parameter;
  • A test method that contains one or more control statements, i.e, if, switch, conditional expression, for, foreach, or while statements;
  • Method with more than one assertion statement with the same parameters;
  • Method contains an instance of a File class without calling the methods Exists(), isFile() or noExists() methods of the object;
  • Method that invokes the Thread.sleep() method;
  • Method does not contain a single assertion statement and @Test (expected) annotation parameter.

What are test smells? 🐞

Test smells are indications of problems or bad practices in software testing that can lead to inefficient testing or even failure to identify software problems s (PALOMBA et al., 2016; PERUMA et. al, 2018; GAROUSI, 2018; ALJEDAANI et al., 2021). The literature presents several types of test smells. GAROUSI, 2018 presents a catalog with more than 80 ones. For this study, we will address the 6 most cited test smells in the literature, which are:

  • Assertion Roulette (AR)
  • Conditional Logic Test (CTL)
  • Duplicate Assert (DA)
  • Resource Optimism (RO)
  • Sleepy Test (ST)
  • Unknown Test (UT)

➡ See definitions and exemplo of test smells

Test smells prevention guideline 🧹

To prevent these kinds of problems known as " test smells" from occurring in test code, it is important to avoid certain scripting structures in the test code. In the following, we will show some structures that will help developers avoid having the following test smells in their test code. These suggested preventions are based on the JUnit 4 framework.

➡ See prevention and exemplo of test smells

Guideline evaluation

In this section, we will present two initiatives that will be carried out by the core and peripheral development teams. The purpose of these activities is to confirm the applicability of our guidelines.

➡ See guideline evaluation on test smells

Contributions 🤝

Contributions to maintain this summary up to date are appreciated and encouraged. Please submit your pull request.

About

Test Smells Prevention Guidelines

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages