Bond: A Spy-based Testing and Mocking Library
Erik Krogen
EECS Department, University of California, Berkeley
Technical Report No. UCB/EECS-2016-116
May 24, 2016
http://www2.eecs.berkeley.edu/Pubs/TechRpts/2016/EECS-2016-116.pdf
In today’s world of software projects that are constantly increasing in complexity and number of contributors, proper testing is essential. Yet, developing tests is a tedious process that is often undervalued and overlooked; most existing research into this problem has been devoted to automated test generation, but manually written tests remain a crucial part of any complete test suite. In this work we introduce spy-based testing, a novel style of unit testing in which developers specify only the variables or objects they are interested in verifying, rather than the specific values they expect. The testing framework aids the developer by collecting values from live execution and verifying them through user interaction, then saving these values to detect future regressions. We have developed Bond, an implementation of spy-based testing in Python, Ruby, and Java, in an effort to provide an easier way for developers to quickly write and maintain unit tests. In addition to the core facets of spy-based testing, Bond contains an integrated mocking library, including record-replay mocking functionality that allows a mock to be created by recording live interactions and replaying stored values back at a later time. We present Bond and discuss its usage, and finally provide case studies demonstrating the potential for Bond to save a significant amount of programming effort when developing tests.
Advisors: George Necula
BibTeX citation:
@mastersthesis{Krogen:EECS-2016-116, Author= {Krogen, Erik}, Title= {Bond: A Spy-based Testing and Mocking Library}, School= {EECS Department, University of California, Berkeley}, Year= {2016}, Month= {May}, Url= {http://www2.eecs.berkeley.edu/Pubs/TechRpts/2016/EECS-2016-116.html}, Number= {UCB/EECS-2016-116}, Abstract= {In today’s world of software projects that are constantly increasing in complexity and number of contributors, proper testing is essential. Yet, developing tests is a tedious process that is often undervalued and overlooked; most existing research into this problem has been devoted to automated test generation, but manually written tests remain a crucial part of any complete test suite. In this work we introduce spy-based testing, a novel style of unit testing in which developers specify only the variables or objects they are interested in verifying, rather than the specific values they expect. The testing framework aids the developer by collecting values from live execution and verifying them through user interaction, then saving these values to detect future regressions. We have developed Bond, an implementation of spy-based testing in Python, Ruby, and Java, in an effort to provide an easier way for developers to quickly write and maintain unit tests. In addition to the core facets of spy-based testing, Bond contains an integrated mocking library, including record-replay mocking functionality that allows a mock to be created by recording live interactions and replaying stored values back at a later time. We present Bond and discuss its usage, and finally provide case studies demonstrating the potential for Bond to save a significant amount of programming effort when developing tests.}, }
EndNote citation:
%0 Thesis %A Krogen, Erik %T Bond: A Spy-based Testing and Mocking Library %I EECS Department, University of California, Berkeley %D 2016 %8 May 24 %@ UCB/EECS-2016-116 %U http://www2.eecs.berkeley.edu/Pubs/TechRpts/2016/EECS-2016-116.html %F Krogen:EECS-2016-116