2009-05-07 82 views
19

在NUnit Gui Runner中,有6个选项卡。通过编写类似如何写入NUnit gui runner的日志选项卡和Console.Error选项卡

Console.WriteLine("This will end up in the Console.Out"); 

我可以写跟踪标签:我可以通过写像写Console.Out

System.Diagnostics.Trace.WriteLine("This will end up on the Trace tab"); 

但是我怎么写其他两个选项卡, “日志”和“Console.Error”?

+7

注意,这些选项卡已合并NUnit的2.5到命名为“文本输出”一个标签。您可以在'设置' - >'图形用户界面' - >'文本输出'中配置哪些输出写入此窗口。如果您想分离出来,也可以创建新的选项卡。 – 2009-05-07 02:19:13

回答

24

要写入Console.Error,你这样做:

Console.Error.WriteLine( “嗒嗒”);

要写入日志,需要在测试项目中配置log4net,然后在项目的.exe.config文件中设置log4net appender。 NUnit的其实是一个有点棘手与log4net的设置,这里的上手点指南:

http://www.softwarefrontier.com/2007/09/using-log4net-with-nunit.html

+0

一位用户在使用此解决方案时遇到问题,并且使用此[备用解决方案](http://gaussc.blogspot.no/2009/02/configuring-nunit-tests-to-work-with.html)进行评论。这在我的VS2013和更新的NUnit测试框架的情况下工作。 – holroy 2015-04-09 10:47:53