使用ReSharper,如何在长时间运行的单元测试中显示调试输出? [英] Using ReSharper, how to show debug output during a long-running unit test?

查看:170
本文介绍了使用ReSharper,如何在长时间运行的单元测试中显示调试输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将xUnit与ReSharper测试运行程序和 xUnitContrib resharper插件一起使用.

I'm using xUnit with the ReSharper test runner and the xUnitContrib resharper plugin.

当我进行长时间运行的测试时,我希望能够将一些进度指示器输出到单元测试输出"窗口中.

When I have a long-running test, I'd like to be able to output some progress indicator to the Unit Test Output window.

我尝试了Debug.WriteLinesTrace.WriteLineConsole.WriteLine.所有这些都具有相同的行为-在测试完成之前,输出窗口中将不显示任何内容.

I've tried Debug.WriteLines, Trace.WriteLine and Console.WriteLine. All of which have the same behavior - nothing shows in the output window until the test has completed.

例如:

[Fact]
public void Test()
{
    Debug.WriteLine("A");
    Trace.WriteLine("B");
    Console.WriteLine("C");

    Thread.Sleep(10000);
}

直到10秒钟过去并且测试完成,测试才会显示任何输出.如何获得输出结果?

The test shows no output until the 10 seconds have elapsed and the test completes. How do I get output along the way?

更新1

我也尝试了MSTest和NUnit. NUnit是唯一一路显示输出的内容.

I tried also with MSTest and NUnit. NUnit is the only one that shows output along the way.

在测试完成之前,MSTest和XUnit不会返回任何输出.奇怪的是,虽然XUnit和NUnit测试输出看起来像这样:

MSTest and XUnit don't return any output until the test completes. The weird part is that while the XUnit and NUnit test output looks like this:

A
B
C

MSTest输出如下:

The MSTest output looks like this:

C


Debug Trace:

A
B

鉴于所有这些变化,我认为答案是由测试运行器实现决定如何以及何时输出.有人知道是否可以配置XUnit测试运行器吗?

Given all of these variations, I think the answer is that it is up to the test runner implementation to decide how and when to output. Does anyone know if it is possible to configure the XUnit test runner?

更新2

我认为这一定是xUnitContrib中的缺陷.发布到他们的 CodePlex问题跟踪器.

I think this must be a deficiency in xUnitContrib. Posted to their CodePlex issue tracker.

推荐答案

Brad Wilson :

这是xUnit.net中的限制,而不是Resharper适配器.

This is a limitation in xUnit.net, not the Resharper adapter.

我们将在xUnit.net的v2中解决这个问题.

We will be addressing this in v2 of xUnit.net.

http://xunitcontrib.codeplex.com/workitem/4160

这篇关于使用ReSharper,如何在长时间运行的单元测试中显示调试输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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