Visual Studio MFC Project Add native test case __MFC

Source: Internet
Author: User

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


About the Microsoft::visualstudio::cppunittestframework Library of documents, go to MSDN to look at the line, some of the macros used, there are instructions.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: