Hi all,
I can't help feeling surprised when people tell me that they are not doing any kind of automated testing of their code. In these days (2013), it as surprising as listening in the news people talking about the "new technologies" when referring to computer based systems, really? new technologies?
I come from a Java background. In the Java world there are no excuses to justify not testing. It is just so easy. Fantastic libraries like
JUnit,
Mockito,
EasyMock, and others effective destroy any barriers to starting testing. No barriers, no excuse.
Recently I started working in a
C++ environment (a long lasting desire of myself). This are dramatically different. In C++ there are many barriers to testing. So, when I joined the team I decided to help destroying all those barriers that were making it easy for developers to justify not testing their code (I still can't believe that someone can say "I don't have time for that". Don't you realise that you will have plenty of time if you start testing, grrrrr).
Enough ranting. I started dipping my toes into the waters of unit testing, mocking and friends in C++, and realised how in fact it is not easy, but as Kennedy said, we choose to do it not because it is easy, but because it is hard (and very useful :)). There are tools available, like
CppTest,
Boost unit tests,
Google test,
Google mock, and they are excellent tools.
Long story short. Are you interested in unit testing your C++ projects? Do you use
CMake to build your projects? Then give a look to this very uber-simple project:
https://github.com/julitopower/CppLittleExercises/tree/master/BoostPointers
Enjoy!!!