[英]How to set Timeout in CppUnitTestFramework (C++) in Visual Studio?
How to Add Timeout for a test method in C++ in Microsoft unit testing using CppUnitTestFramework ? 如何使用CppUnitTestFramework在Microsoft单元测试中为C ++中的测试方法添加超时? Most of the Solutions I found online are for CSharp projects where I can add lines like [TEST_METHOD,TIME_OUT(80)] or such ,but those are not working while testing C++ (VC++) code
我在网上找到的大多数解决方案都适用于CSharp项目,我可以添加[TEST_METHOD,TIME_OUT(80)]等行,但是在测试C ++(VC ++)代码时这些不起作用
I have tried the below code 我试过下面的代码
#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());
}
};
}
Use managed test classes. 使用托管测试类。 and you can keep Timeouts in that .
你可以保持超时。
[TestMethod(), Timeout(3000)]
void functionName()
{
//
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.