This event has ended. View the official site or create your own event → Check it out
This event has ended. Create your own
Please visit the C++Now website.
View analytic
Wednesday, May 11 • 4:30pm - 5:15pm
Friendship in Service of Testing

Log in to save this to your schedule and see who's attending!

Unit testing of object-oriented code requires two fundamental artifacts: replacing some of the original code with some kind of test doubles (aka dependency injection), and providing extra access to these private dependencies. In most cases we cannot apply link-time or preprocessor based dependency injection, therefore a typical testable unit uses additional interfaces or template type parameters for pure testing purposes. Thus a unit which we developed without testing in mind might have to be changed intrusively for testing. These changes can take us far away from the original natural design of the unit. As a result, in C++, test code is often badly interwoven with the unit we want to test. We've seen such interleaving in the software world before: exceptions and aspect oriented programming were both invented to try to eliminate this kind of interleaving of independent aspects. In this talk I'd like to demonstrate the above problems using code examples to show the decay of original intentions. I briefly discuss current possible directions to solve the dependency injection problem: e.g. using compile-time seams. Then, I will overview the current (partial) solutions for adding extra access for private data, like using friends, the Attorney-Client idiom, or exploiting privates using explicit template instantiations. Regarding to extra access of private data, I will present how a minimal language extension would help and make the testing code less intrusive. Open non-intrusive friend declarations could provide a good method to separate the test related code from the original intentions. We implemented a proof-of-concept solution, based on LLVM/Clang to show that such constructs can be established with a minimal syntactical and compilation overhead.

avatar for Gábor Márton

Gábor Márton

PhD Student, Eötvös Loránd University
Gábor has been working with C++ since 2000. Currently he is working in the finance industry. In 2013 he started his PhD studies at Eötvös Loránd University, Budapest, Hungary . His topic is to reveal methods making C++ testing easier. He is also interested in compilers, coroutines, ASIO and in lock-free programming.
avatar for Zoltán Porkoláb

Zoltán Porkoláb

Ericsson & Eötvös Loránd University
Dr. Zoltán Porkoláb is an Associate Professor of Faculty of informatics at Eötvös Loránd University (ELTE), Budapest, Hungary. At the same time, he holds Principal C++ Developer position at Ericsson Hungary Ltd.

Wednesday May 11, 2016 4:30pm - 5:15pm
Flug Auditorium

Attendees (28)