![](/img/trans.png)
[英]How to get the $(ProjectDir) path in a Visual Studio native C++ Unit Testing using CppUnitTestFramework?
[英]How to set Timeout in CppUnitTestFramework (C++) in Visual Studio?
如何使用CppUnitTestFramework在Microsoft单元测试中为C ++中的测试方法添加超时? 我在网上找到的大多数解决方案都适用于CSharp项目,我可以添加[TEST_METHOD,TIME_OUT(80)]等行,但是在测试C ++(VC ++)代码时这些不起作用
我试过下面的代码
#include "stdafx.h"
#include "CppUnitTest.h"
#include "../src/factorial_dp.cpp"
#include "stdio.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace spec
{
TEST_CLASS(factorial_dpSpec)
{
public:
//Add Timout for these methods
TEST_METHOD(Smallnumber)
{
int result = fact(5);
Assert::AreEqual(120, result, L"5 fact should be 120", LINE_INFO());
}
};
}
使用托管测试类。 你可以保持超时。
[TestMethod(), Timeout(3000)]
void functionName()
{
//
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.