理论与测试 Nunit [英] Theory vs Test Nunit

查看:48
本文介绍了理论与测试 Nunit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚阅读了 Nunit 2.5 文档并遇到了 Theory属性,我在理解这与普通单元测试有何不同以及如何使用它时有点困难.

I was just reading through the Nunit 2.5 docs and came across the Theory attribute, and I'm having a little bit trouble understanding how this is different to a normal unit test and how it could be used.

它与普通测试有何不同?

What makes it different from a normal test?

你会在什么情况下使用这种测试?

What situations would you use this kind of test?

我似乎无法理解它:(

推荐答案

A Theory 类似于参数化测试,具有定义必须通过的假设的附加能力,这些假设在实际执行测试及其断言之前进行检查.

A Theory is similar to a parameterized test, with the additional ability to define assumptions under which it must pass, which are checked before actually performing the test and its assertions.

基本上,如果您有大量数据点并且想要检查应该保证的特定行为,则可以使用它 - 但并非总是如此,仅在特定前置条件.

Basically, it could be used if you have a lot of data points and want to check a certain behaviour that should be guaranteed - but not always, only under certain preconditions.

这篇关于理论与测试 Nunit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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