If you are a really old school C or C++ developer, you know how it is hard to compile, build, link and test your code. Sometimes it takes hours to reach your goal, but in modern approach for C++ development, tools and testing frameworks give you ability to test your code before you write. You have quality code on your hands even when you publish your first release.

Test first approach changed our way of programming, actually I met test first approach in 2006 (not for C++ but for Java and C#) and before this I was developing C++ with classical first develop and then test approach. To be honest, in my country a lot of companies dont like test driven development and test first approach, not specially for compiled languages like C / C++ but also for interpreted languages. Because of this in your professional life, it is not always easy to use this approach. Ok, but I was some of the lucky ones who were given permission to develop their software by following test driven development techniques. It was for Java and Php :\, but still I was able to apply those techniques and develop my skills on test driven development.

Ok, sorry I am not straight to the point this time, maybe I can add some posts about Unit testing, test driven development and test first approach, now lets start with C++ Unit testing frameworks.

Here are some of the C++ Unit testing frameworks on wikipedia http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C.2B.2B. I used two of them and I really dont have any idea about the others, I used following C++ unit testing frameworks

  1. Googletest
  2. CppUnit

and I must say that Googletest is the better than CppUnit, and also Google has a mocking framework that you can use with your Googletest unit tests. CppUnit is also easy to use with a cool Test Results window similar to Junit. I was not happy with Googletest, because it did not show any test result window in graphics. I just see test results in text when I use Googletest.

c-unit-run-test-orig

CppUnit tests

I am using Netbeans when I am developing C++, I was using Anjuta and CodeBlocks in ancient ages. But I feel comfortable while I am using Netbeans. I think this is because of I have to write c++, java and php at the same time. You can use vim or any other ides while using googletest and test driven approach.

I am also using Netbeans generated Makefile, but I am planning to use CLion and CMake in near future. Anyway ide is not important, but here I am going to use Netbeans.

I will continue editing this post, but after going to the dentist today and getting some pills and anesthesia I really dont have any power 😐