2

I have a couple of MFC applications. I don't want to unit-test UI but test all logics in the application for TDD. According to my research, I found two ways

  1. Using C++/CLI and MSTest to build managed tests after restructuring your code into a static library
  2. Using Google C++ Testing framework

I was almost sold to MSTest approach but changed my mind after reading comments on a blog about it. I want to spend my time to debug my application but not my tests for the application.

I am sure there are a lot of developers who are practicing TDD in C++. I would like to hear from them which way above is a good practice.

Tae-Sung Shin
  • 20,215
  • 33
  • 138
  • 240
  • [This](http://stackoverflow.com/questions/4775253/boost-test-vs-google-test-framework) might be an interesting read – Ken Wayne VanderLinde Jan 28 '12 at 06:02
  • possible duplicate of [Comparison of c++ unit test frameworks](http://stackoverflow.com/questions/242926/comparison-of-c-unit-test-frameworks) – Martin Ba Jan 28 '12 at 09:58
  • @Martin, I've already read the question/answers but it does not provide with what I wanted. What I'd like to know is not the list of test frameworks but the reasons to choose them or not. – Tae-Sung Shin Jan 28 '12 at 17:40
  • @Paul - "I'd like to know ... not the list ... but the reasons to choose them or not" - and you'll find plenty of answers there and on links provided by these. – Martin Ba Jan 29 '12 at 17:44

3 Answers3

4

The Google C++ testing framework is well worth looking into, I've used it on a number of projects. You should be able to mock the UI classed you don't want to use.

Ian Collins
  • 141
  • 2
1

Boost.Test is also a very good testing framework.

Martin Ba
  • 37,187
  • 33
  • 183
  • 337
0

I would suggest looking into Catch (C++ Adaptive Test Cases in Headers). Since it is header based it is very easy to get started with. In my experience it is also very easy to work with and I find that I write tests much faster in Catch than any other framework I have tried so far. The following blog post by the author is a very good starting point: Unit Testing in C++ and Objective-C just got easier.

TAS
  • 2,039
  • 12
  • 17