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