好吧,这听起来似乎太简单了,但是如何使特定的测试/测试集显示为特定功能的单元测试,例如当您在函数体内右键单击时调用相同的内容? / p>
(运行测试选项)
我可以将测试显示在Test Explorer的“所有测试”中,也可以运行它们,但是从此菜单选项中,我总是得到“ No tests found to run.
”,这是我的unittests.cpp
供参考:
#include "CppUnitTestLogger.h"
#include "CppUnitTest.h"
#include "CalculationObj.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTests
{
TEST_CLASS(CCalculationObjTest)
{
public:
BEGIN_TEST_METHOD_ATTRIBUTE(CCalculationObj_AdditionTest)
TEST_OWNER(L"OwnerName")
TEST_PRIORITY(1)
END_TEST_METHOD_ATTRIBUTE()
TEST_METHOD(CCalculationObj_AdditionTest)
{
int n1 = 100, n2 = 200;
int nOutPut = 0;
try
{
CCalculationObj calcObj;
calcObj.Addition(n1, n2, &nOutPut);
Assert::AreEqual(nOutPut, 300);
}
catch (const std::exception& e)
{
Logger::WriteMessage(e.what());
}
}
};
}
我正在使用VS2015
,仅对Native Unit Tests Framework
感兴趣。谢谢!