mercredi 6 janvier 2016

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 ? 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

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());
        }

    };
}

Aucun commentaire:

Enregistrer un commentaire