24 03, 2011

Screenshot on Test Failure

By | 2011-03-24T08:23:08+00:00 March 24th, 2011|Coded UI, Software Testing, Team Foundation Server|2 Comments

Neeraja Reddy from the testing team at Microsoft just provided a pretty cool code snippet to perform a screencapture - programmatically of a failed test: [TestCleanup()] public void MyTestCleanup() {     if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)     {         Image img = UITestControl.Desktop.CaptureImage();         img.Save(Path.Combine(TestContext.TestResultsDirectory, "FailureSnapshot.png"));     } } By placing this code in the TestCleanup [...]