VS2015單元測試

1、C++在VS2015上進行單元測試架構

        1.建立單元測試項目;函數

        2.包含#include "CppUnitTest.h"文件和using namespace Microsoft::VisualStudio::CppUnitTestFramework;聲明;單元測試

        3.類聲明TEST_CLASS(TestCppWin)和函數聲明TEST_METHOD(CppWin_WinShareMemory);測試

        4.若是是32位單元測試,那麼已經能夠了;若是須要64位程序,選擇【測試】【測試設置】【默認處理器體系架構】選擇x64;spa

        5.更改測試平臺爲x64,從新編譯測試;code

        經常使用的測試代碼:it

Assert::AreEqual() / Assert::AreNotEqual();
    Assert::AreSame() / Assert::AreNotSame();
    Assert::IsTrue() / Assert::IsFalse();
    Assert::IsNull() / Assert::IsNotNull();
    Assert::ExpectException();
    Assert::Fail();
相關文章
相關標籤/搜索