添加自定义消息进行单元测试结果 [英] Add custom message to unit test result

查看:215
本文介绍了添加自定义消息进行单元测试结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法,我可以添加自定义消息到测试方法的结果?我想提出一个秒表上的代码的一部分,看多久,它的运行。我并不需要测试,这是一个特定的时间框架内运行,只是想在结果窗口中什么经过时间去看看。

Is there a way I can add a custom message to the result of a test method? I want to put a stopwatch on part of the code to see how long its running. I don't need to test that it's running within a certain time frame, just want to see in the result window what the elapsed time was.

推荐答案

您正在使用MSTest的假设,你可以使用

Assuming you are using MSTest, you can use

System.Diagnostics.Trace.WriteLine("Hello World");

为任何你想要的输出。它会在测试运行的全部结果显示出来。

To output whatever you'd like. It will show up in the full results of the test runner.

这篇关于添加自定义消息进行单元测试结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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