与Debug.Assert的NUnit的冲突 [英] NUnit conflict with Debug.Assert

查看:119
本文介绍了与Debug.Assert的NUnit的冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用NUnit写了libary我的一个同事写单元测试。他的图书馆中含有大量的Debug.Asserts触发无效投入。当我在写单元测试,并以他的图书馆给予无效的输入,他Debug.Assert的抛出了一个消息框抱怨糟糕的输入。

I'm using NUnit to write unit tests for a libary a colleague of mine has written. His library contains a lot of Debug.Asserts which triggers on invalid input. When I'm writing the unit tests and give invalid input to his library, his Debug.Assert throws up a message box complaining about the bad input.

我觉得这是一件好事,他的库抛出了上输入无效的断言,但在同一时间,我想单元测试覆盖错误输入。但是,当我这样做,消息框显示了,我必须手动点击确定继续余下的单元测试。

I feel that it's a good thing that his library throws up an assert on invalid input, but at the same time I want the unit tests to cover bad input. But when I do this, the message box shows up and I have to manually click OK to continue with the remaining unit tests.

在情况下,它是不明确的,我问题是,单元测试过程的Debug.Assert的停止。人们应该之前的任何签运行他们的单元测试,它应该是自动的,除非测试失败。

In case it isn't clear, my problem is that the unit test process stops on the Debug.Assert. People are supposed to run their unit tests prior to any checkin and it's supposed to be automatic and should not throw up messages unless a test has failed..

什么是最好的在这种情况下的做法

What's the "best" approach in this case?

推荐答案

在MSDN文档中的 Debug.Assert的方法。特别是在备注,它解释了如何禁用的用户界面:

Take a look at the MSDN documentation for the Debug.Assert method. Specifically under "Remarks", it explains how you can disable the UI:

<configuration>
  <system.diagnostics>
    <assert assertuienabled="false" logfilename="c:\\myFile.log" />
  </system.diagnostics>
</configuration>



所以我建议应用程序配置文件在默认情况下有这样和你的同事就断言切换到每当他觉得这有用的UI这样做。

Therefore I'd suggest that the application config file has this by default and your colleague switches on Assert to UI whenever he feels it useful to do so.

这篇关于与Debug.Assert的NUnit的冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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