Tae-Sung Shin
Tae-Sung Shin

Reputation: 20643

Practical way to test native C++ code in Windows?

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.

Upvotes: 2

Views: 296

Answers (3)

TAS
TAS

Reputation: 2079

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.

Upvotes: 0

Martin Ba
Martin Ba

Reputation: 38775

Boost.Test is also a very good testing framework.

Upvotes: 1

Ian Collins
Ian Collins

Reputation: 141

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.

Upvotes: 4

Related Questions