Assert.That 与 Assert.True [英] Assert.That vs Assert.True

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

问题描述

喜欢什么:

Assert.That(obj.Foo, Is.EqualTo(true))

Assert.True(obj.Foo)

对我来说,这两个断言是等价的,那么应该首选哪一个?

For me, both asserts are equivalent, so which one should be prefered?

推荐答案

在这种特殊情况下,没有区别:您将看到大致相同详细程度的输出(即它告诉您预期会发生的事情)评估为 true 已评估为 false).同样适用于

In this particular case, there is no difference: you will see the output of roughly the same level of detail (i.e. it tells you that something that was expected to evaluate to true has evaluated to false). Same goes for

Assert.IsTrue(obj.Foo);

Assert.That(obj.Foo, Is.True);

您的团队应该选择一种断言风格,并在所有测试中坚持使用.如果您的团队更喜欢 Assert.That 风格,那么您应该使用 Assert.That(obj.Foo, Is.True).

Your team should pick one style of assertions, and stick with it throughout all your tests. If your team prefers the Assert.That style, then you should use Assert.That(obj.Foo, Is.True).

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

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