Skip to content

Instantly share code, notes, and snippets.

@gofer
Created August 22, 2016 07:48
Show Gist options
  • Save gofer/582c841831ccba70b1facd291bdadb96 to your computer and use it in GitHub Desktop.
Save gofer/582c841831ccba70b1facd291bdadb96 to your computer and use it in GitHub Desktop.
アンマネージなVC++でUnit Test

アンマネージなVC++でUnit Test

Debugのプロパティを変更

  1. 全般→構成の種類をdllにする
  2. C/C++→インクルードディレクトリに$(VCInstallDir)UnitTest\includeを追加
  3. リンカー→追加のライブラリディレクトリに$(VCInstallDir)UnitTest\libを追加
  4. テストの実行はテストエクスプローラから実行

テストコード例

#if _DEBUG
#include <CppUnitTest.h>
#include <CppUnitTestAssert.h>
#include <CppUnitTestLogger.h>

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace TestClassName
{
	TEST_CLASS(TestClassName)
	{
	public:
		TEST_METHOD(TestCaseName)
		{
			Assert::AreEqual(3, 3);
		}
	};
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment