A metrics suite for JUnit test code: a multiple case study on open source software


  • Fadel Toure University of Quebec
  • Mourad Badri University of Quebec
  • Luc Lamontagne Laval University


Software testing, Unit testing, Testing effort, JUnit code, Metrics, Principal components analysis, Clustering techniques, Correlation analysis and linear regression analysis



The code of JUnit test cases is commonly used to characterize software testing effort. Different metrics have been proposed in literature to measure various perspectives of the size of JUnit test cases. Unfortunately, there is little understanding of the empirical application of these metrics, particularly which metrics are more useful in terms of provided information.;


This paper aims at proposing a unified metrics suite that can be used to quantify the unit testing effort. We addressed the unit testing effort from the perspective of unit test case construction, and particularly the effort involved in writing the code of JUnit test cases. We used in our study five unit test case metrics, two of which were introduced in a previous work. We conducted an empirical study in three main stages. We collected data from six open source Java software systems, of different sizes and from different domains, for which JUnit test cases exist. We performed in a first stage a Principal Component Analysis to find whether the analyzed unit test case metrics are independent or are measuring similar structural aspects of the code of JUnit test cases. We used in a second stage clustering techniques to determine the unit test case metrics that are the less volatile, i.e. the least affected by the style adopted by developers while writing the code of test cases. We used in a third stage correlation and linear regression analysis to evaluate the relationships between the internal software class attributes and the test case metrics.;

Results and Conclusions

The main goal of this study was to identify a subset of unit test case metrics: (1) providing useful information on the effort involved to write the code of JUnit test cases, (2) that are independent from each other, and (3) that are the less volatile. Results confirm the conclusions of our previous work and show, in addition, that: (1) the set of analyzed unit test case metrics could be reduced to a subset of two independent metrics maximizing the whole set of provided information, (2) these metrics are the less volatile, and (3) are also the most correlated to the internal software class attributes.;



Download data is not yet available.




How to Cite

Toure, F., Badri, M., & Lamontagne, L. (2014). A metrics suite for JUnit test code: a multiple case study on open source software. Journal of Software Engineering Research and Development, 2, 14:1 – 14:32. Retrieved from https://sol.sbc.org.br/journals/index.php/jserd/article/view/398



Research Article