C# unit test smell detection in visual studio
Professor Advisor
Abstract
Los Test Smells son malas pr´acticas de programaci´on que suelen indicar problemas de dise˜no
en c´odigo de testeo. Tienen un impacto negativo en la comprensibilidad y mantenibilidad de
los tests, y suelen mantenerse en el c´odigo por mucho tiempo luego de ser introducidos. Esto
es debido a que los desarrolladores no suelen darles importancia, a pesar de las los problemas
que trae su presencia.
Por lo tanto, hemos desarrollado una herramienta de detecci´on y refactoring, disponible
como paquete NuGet para el editor Visual Studio, que ayuda a los usuarios a identificar test
smells a medida que van escribiendo c´odigo, y facilita el proceso de arreglarlos o eliminarlos.
La herramienta detecta 14 smells distintos, destac´andolos como avisos en el editor, y ofrece
refactorings autom´aticos para 7 de los smells.
Tambi´en hemos desarrollado una manera alternativa de analizar proyectos mediante una
herramienta de linea de comando, que permite ejecutar los mismos analizadores sin necesidad
de instalar nada en el proyecto. Esta herramienta genera un reporte con la lista de todos los
smells identificados, permitiendo al usuario obtener informaci´on detallada de la repartici´on
y naturaleza de los smells de su proyecto. Esto tambi´en puede ser integrado a una pipeline
de git, para correr al an´alisis antes de cada commit o pull request.
A partir de una validaci´on manual de la herramienta sobre un corpus de tests industriales,
hemos determinado que el analizador tiene una precisi´on suficiente para ser ´util en un
ambiente de producci´on, y ayudar a los desarrolladores a escribir c´odigo de testeo mas limpio
y mantenible. Test smells are bad programming practices in unit test code that indicate possible
design problems within the tests. They have a negative impact on test readability and
maintainability, and have been shown to stay in code for long amounts of time, due to
developer perception not lining up with the negative consequences of their presence.
Thus, we have developed a set of analyzers and codefixes, available as a Visual Studio
NuGet package, to helps developers catch test smells as they introduce them, and expedite
the process of fixing them. The tool detects and reports a total of 14 different test smells as
warnings inside the editor and offers automatic fixing of 7 of the aforementioned smells as
code refactorings.
We have also developed a command line tool that allows developers to run the same
analysis without having to install anything, generating a list report of all smells found. This
allows developers to run analysis before commits as a git action or use external tools to get
useful information about the distribution and nature of smells affecting a project.
From manual validation in industrial test code, we conclude that the tool has sufficient
precision to prove useful in a production environment and help developers write cleaner and
more maintainable test code.
xmlui.dri2xhtml.METS-1.0.item-notadetesis.item
Memoria para optar al título de Ingeniero Civil en Computación
Collections
The following license files are associated with this item: