Question

I'm using VS2010.

TestContext.AddResultFile() produces an erratic behaviour during my unit test. Sometimes it adds the files to the report, sometimes it doesn't. After running the same basic dummy test again and again, in around 50% of the cases the files are not added to the report.

Did anybody else notice this? What is the solution?

Was it helpful?

Solution

The problem was that I was opening the test results too soon. The test run is marked as fail while the TestCleanup() method is still running.

Since the TestContext.AddResultFile() was called by TestCleanup(), when I clicked the test result too soon, the report would display, but without the additional result files. So you shouldn't open the test report while the Results window says "Test run completing...", you should wait until it says "Test run completed" or "Test run failed."

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top