PyNose: A Test Smell Detector For Python

08/10/2021
by   Tongjie Wang, et al.
0

Similarly to production code, code smells also occur in test code, where they are called test smells. Test smells have a detrimental effect not only on test code but also on the production code that is being tested. To date, the majority of the research on test smells has been focusing on programming languages such as Java and Scala. However, there are no available automated tools to support the identification of test smells for Python, despite its rapid growth in popularity in recent years. In this paper, we strive to extend the research to Python, build a tool for detecting test smells in this language, and conduct an empirical analysis of test smells in Python projects. We started by gathering a list of test smells from existing research and selecting test smells that can be considered language-agnostic or have similar functionality in Python's standard Unittest framework. In total, we identified 17 diverse test smells. Additionally, we searched for Python-specific test smells by mining frequent code change patterns that can be considered as either fixing or introducing test smells. Based on these changes, we proposed our own test smell called Suboptimal assert. To detect all these test smells, we developed a tool called PyNose in the form of a plugin to PyCharm, a popular Python IDE. Finally, we conducted a large-scale empirical investigation aimed at analyzing the prevalence of test smells in Python code. Our results show that 98 contain at least one test smell. Our proposed Suboptimal assert smell was detected in as much as 70.6 the list.

READ FULL TEXT
research
11/09/2021

An Empirical Study of Automated Unit Test Generation for Python

Various mature automated test generation tools exist for statically type...
research
07/12/2022

Making Python Code Idiomatic by Automatic Refactoring Non-Idiomatic Python Code with Pythonic Idioms

Compared to other programming languages (e.g., Java), Python has more id...
research
12/21/2021

AmPyfier: Test Amplification in Python

Test Amplification is a method to extend handwritten tests into a more r...
research
03/30/2022

A Large-Scale Comparison of Python Code in Jupyter Notebooks and Scripts

In recent years, Jupyter notebooks have grown in popularity in several d...
research
04/11/2023

A Data Set of Generalizable Python Code Change Patterns

Mining repetitive code changes from version control history is a common ...
research
03/24/2023

Testability Refactoring in Pull Requests: Patterns and Trends

To create unit tests, it may be necessary to refactor the production cod...
research
07/20/2020

Jupyter Notebooks on GitHub: Characteristics and Code Clones

Jupyter notebooks have emerged as a standard tool for data science progr...

Please sign up or login with your details

Forgot password? Click here to reset