附加图片到MSTest的测试报告 [英] Attach an image to a test report in MSTest

查看:514
本文介绍了附加图片到MSTest的测试报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用连接到Team Foundation Server 2010的Visual Studio 2010和我们使用MSTest的创建单元测试。

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

是否可以附加图片到测试报告,因此测试失败时,我们可以想像的东西吗?

这图像例如可以为UI测试或应用程序的屏幕截图图形可视化的测量数据。

This image can for example be a screenshot of the application for UI tests or a graph visualizing measurement data.

推荐答案

使用的 TestContext.AddResultFile 方式:

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; }
}

这篇关于附加图片到MSTest的测试报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆