TY - GEN
T1 - What do the asserts in a unit test tell us about code quality? A study on open source and industrial projects
AU - Aniche, Mauricio Finavaro
AU - Oliva, Gustavo Ansaldi
AU - Gerosa, Marco Aurélio
PY - 2013
Y1 - 2013
N2 - 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.
AB - 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.
KW - code quality
KW - code smells
KW - mining software repositories
KW - unit test feedback
KW - unit testing
UR - http://www.scopus.com/inward/record.url?scp=84877288408&partnerID=8YFLogxK
UR - http://www.scopus.com/inward/citedby.url?scp=84877288408&partnerID=8YFLogxK
U2 - 10.1109/CSMR.2013.21
DO - 10.1109/CSMR.2013.21
M3 - Conference contribution
AN - SCOPUS:84877288408
SN - 9780769549484
T3 - Proceedings of the European Conference on Software Maintenance and Reengineering, CSMR
SP - 111
EP - 120
BT - Proceedings of the 17th European Conference on Software Maintenance and Reengineering, CSMR 2013
T2 - 17th European Conference on Software Maintenance and Reengineering, CSMR 2013
Y2 - 5 March 2013 through 8 March 2013
ER -