An empirical evaluation for object initialization of member variables in unit testing

Authors Stefan Fischer
Evelyn Nicole Haslinger
Markus Zimmermann
Hannes Thaller
Editors Martin Pinzger
Rudolf Ramler
Title An empirical evaluation for object initialization of member variables in unit testing
Booktitle Proceedings of the 2020 IEEE 3rd International Workshop on Validation, Analysis, and Evolution of Software Tests (VST'20)
Type in proceedings
Publisher IEEE
ISBN 978-1-7281-6271-3
Month February
Year 2020
Pages 8-11
SCCH ID# 20004
Abstract

Automated test case generation techniques usually aim to maximize some coverage criteria. For object oriented languages, like Java, the branches that can be reached in source code, frequently depend on the internal object state. Meaning certain branches will only be taken, if fields inside the tested class are set to specific values. It is however not obvious how much of the internal object state can be controlled. In this paper, we analyzed a corpus of 110 open source systems to evaluate how settable their classes are. Meaning we looked for ways that fields inside classes can be written. For instance, we analyzed the source code to identify setter methods that can be used to set the values of a field. Our results show that 66.5% of fields can be set to a desired value, while 31.5% of fields may be only settable to particular values or require a more in depth analysis. Only for 2% of fields, we did not find any way to set their values.