mercredi 22 avril 2015

Is it possible to CPPUnitTestFrameWork::Assert for locations not in main thread?

I have a set of unit tests that use multiple threads to stress test a server component. I want the test reports to meaningfully reflect where an error occurred. However when I Assert::Fail in a different thread the test is broken instead of reporting success or failure. I came up with the following solution which logs the correct location but when you click on it in the ui it still goes to where you called Assert from. Is there a way to fix that? Just want to make sure I am really doing this the best way. TEST_METHOD(A_Thread_Test) { __LineInfo line(__WFILE__, __FUNCTION__, __LINE__); { boost::thread t([&]() { line.line = __LINE__; line.pszFile = __WFILE__; line.pszFunc = reinterpret_cast<const unsigned char*>(__FUNCTION__); }); boost::thread_guard<> g(t); } Assert::Fail(L"I threw an exception", &line); }

Aucun commentaire:

Enregistrer un commentaire