What do the asserts in a unit test tell us about code quality? A study on open source and industrial projects

Mauricio Finavaro Aniche, Gustavo Ansaldi Oliva, Marco Aurélio Gerosa

Research output: Chapter in Book/Report/Conference proceedingConference contribution

11 Scopus citations

Abstract

Unit tests and production code are intrinsically connected. A class that is easy to test usually presents desirable characteristics, such as low coupling and high cohesion. Thus, finding hard-to-test classes may help developers identify problematic code. Many different test feedbacks that warn developers about problematic code were already catalogued. In this paper, we argue that analyzing assert instructions in unit tests also aid in identifying and reasoning about potentially problematic pieces of code. We report an analysis conducted with both open source and industry projects relating assert instructions in a unit test with quality measures of the code being tested. We observed that when a production method has a unit test that uses the "assert" instruction in more than one object instance, it often exhibits higher cyclomatic complexity, number of lines of code, or higher number of method invocations. It means that developers should monitor the number of asserts in a unit test as it may indicate problems in the production code.

Original languageEnglish (US)
Title of host publicationProceedings of the 17th European Conference on Software Maintenance and Reengineering, CSMR 2013
Pages111-120
Number of pages10
DOIs
StatePublished - 2013
Externally publishedYes
Event17th European Conference on Software Maintenance and Reengineering, CSMR 2013 - Genova, Italy
Duration: Mar 5 2013Mar 8 2013

Publication series

NameProceedings of the European Conference on Software Maintenance and Reengineering, CSMR
ISSN (Print)1534-5351

Conference

Conference17th European Conference on Software Maintenance and Reengineering, CSMR 2013
Country/TerritoryItaly
CityGenova
Period3/5/133/8/13

Keywords

  • code quality
  • code smells
  • mining software repositories
  • unit test feedback
  • unit testing

ASJC Scopus subject areas

  • Software

Fingerprint

Dive into the research topics of 'What do the asserts in a unit test tell us about code quality? A study on open source and industrial projects'. Together they form a unique fingerprint.

Cite this