Visual Studio MFC Project Add native test case
Preface
School graduation design To do an MFC grab package project, but in the company has been using Java, writing is the Java unit Test, for C + +, and is an MFC library under the project, completely do not know how to start. Search on the Internet, the data is relatively small, in a patchwork, finally ran up a single test, so this record. This single measurement uses the Microsoft::visualstudio::cppunittestframework library, which is a built-in unit test library for Visual Studio, which facilitates a practical environment for Visual Studio 2012 MFC Project windows8.1 microsoft::visualstudio::cppunittestframework Library Environment Reconstruction steps
Right-click Properties on the item under test, setting the Configuration Manager
New "unit Test" configuration item
To set a project as a DLL
Add Test library Content
Add Precompiled Headers
Single Test Cases
#include "stdafx.h"
#ifdef _test //precompiled headers that are only measured under the unit TEST configuration
#include "CppUnitTest.h"
using namespace Microsoft::visualstudio::cppunittestframework;
namespace classnametest{
Test_class (classnametest) {public
:
test_class_initialize (classnametestinit {
}
test_class_cleanup (classnametestend) {
}
Test_method (methodname) {
//test content
}
private:
//...
}
#endif
About the Microsoft::visualstudio::cppunittestframework Library of documents, go to MSDN to look at the line, some of the macros used, there are instructions.