Attach Image to MSTest Test Report

We use Visual Studio 2010, connected to Team Foundation Server 2010, and we use MSTest to create our unit tests.

Is it possible to attach an image to the test report, so when the test fails, can we visualize something?

This image may be, for example, a screenshot of a user interface test application or a graph displaying measurement data.

+7
source share
1 answer

Use the TestContext.AddResultFile method:

 [TestClass] public class UnitTest { [TestCleanup] public void TestCleanup() { if (TestContext.CurrentTestOutcome == UnitTestOutcome.Passed) TestContext.AddResultFile(testPassedFile); else TestContext.AddResultFile(testFailedFile); } [TestMethod] public void TestMethod() { } public TestContext TestContext { get; set; } } 
+8
source

All Articles