Visual Studio 11 Development Guide (15) C ++ 11 unit test

Source: Internet
Author: User
Start Visual Studio 11.

C ++ unit test (CPP)

Unit Test Project of the Local Machine

You can write unit tests after creating the smallest framework.

1.#include "stdafx.h"2.#include "CppUnitTest.h"3. 4.using namespace Microsoft::VisualStudio::CppUnitTestFramework;5. 6.namespace UnitTest17.{        8.    TEST_CLASS(UnitTest1)9.    {10.    public:11.        12.        TEST_METHOD(TestMethod1)13.        {14.            Assert::AreEqual(42,42);15.        }16. 17.    };18.}

To make the test active, you must compile the project.

Note: If you get the message "c1083 fatal error: cannot open the include file: 'cppunittest. h': no such file or directory ", it must add the following path, including and library, input file (86) \ Microsoft Visual Studio 11.0 \ Vc \ unittest \ include "input file (86) \ Microsoft Visual Studio 11.0 \ Vc \ unittest \ Lib"

To run the test, select this window:View-other windows. Unit Test Resource Manager

If the test is successful, the following window is displayed:

The content of the Visual C ++ testing framework at the next level will be returned, but note that it is based onMicrosoft. visualstudio. testtools. cppunittestframework. LibLibrary and header fileCppunittest. H, cppunittestcommon. H, cppunittestassert. H, cppunittestlogger. hMacro contained in the file

For those with a framework for operating unit testing. Set the network, including methods suchAssert: areequal, notequal, isnotnull, and so on, and the log method of the message logger: writemessage.

 

 

Download vs11 now

Http://www.microsoft.com/click/services/Redirect2.ashx? Cr_cc = 200098144

 

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.