I have the following "Windows Store/Metro Style" test methods in VS 2012 C++/CX
This one succeeds, which is ok
TEST_METHOD(TestMethod)
{
bool passed = false;
concurrency::event finished;
finished.reset();
auto testTask = concurrency::create_task( [&finished, &passed]()
{
passed = true;
finished.set();
});
finished.wait(100000);
Assert::IsTrue(passed);
}
This one fails, which is also ok:
TEST_METHOD(TestMethod)
{
bool passed = true;
concurrency::event finished;
finished.reset();
auto testTask = concurrency::create_task( [&finished, &passed]()
{
passed = false;
finished.set();
});
finished.wait(100000);
Assert::IsTrue(passed);
}
But for some reason, this test does not fail:
TEST_METHOD(FailedTest)
{
concurrency::event finished;
finished.reset();
auto testTask = concurrency::create_task( [&finished]()
{
Assert::IsTrue(false);
finished.set();
});
finished.wait(100000);
}
Am I doing something wrong?
As a side note, a possible work-around could be to put all the results of my tests in variables and "test" them all after finished.wait(100000);
, but I still would like to know if there is something actually wrong with what I am doing.
The test does fail. If you open the Tests Output window (View -> Output, then under Show output from, select Tests), you should see the following:
In the Test Explorer, the test should appear grayed out because the test failed to run to completion. Unfortunately, because the test run fails completely, if the test had at any time in the past passed, the test still appears in the Passed Tests group and still has a green check mark next to it. Rely on the grayed-out name as an indication that the test did not run to completion.
I would recommend opening a bug on Microsoft Connect concerning the confusing UI in the Test Explorer in this scenario (if you open a bug, please post the link either as a comment to this answer or in your question, so others can find it).