什么是Assert.Equals的使用情况如何? [英] What is the usage of Assert.Equals?

查看:1026
本文介绍了什么是Assert.Equals的使用情况如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的单元测试我当前的项目并在一些奇怪的来了。在.NET单元测试库既有Assert.Equals和Assert.AreEqual。对于Assert.Equals的言论说使用断言.AreEqual比较两个对象,但没有给出理由,为什么超过Assert.Equals这样做。有人可以解释的时候,你应该在单元测试中如果曾经和Assert.Equals和Assert.AreEqual之间的区别使用Assert.Equals,?

I am working on Unit Testing for my current project and came across something odd. The .Net UnitTesting library has both Assert.Equals and Assert.AreEqual. The remarks for Assert.Equals say to use Assert.AreEqual to compare two objects, but gives no reason as to why to do so over Assert.Equals. Can somebody explain when you should use Assert.Equals in unit testing, if ever and the difference between Assert.Equals and Assert.AreEqual?

推荐答案

Assert.Equals 只是等于从继承方法的对象。它无关,与单元测试,而事实上,已经没有用了。

Assert.Equals is just the Equals method inherited from object. It has nothing to do with unit testing, and in fact, has no use.

要更精确, Assert.Equals 是完全一样的的Object.Equals 的Object.Equals 有使用。

To be more precise, Assert.Equals is exactly the same as Object.Equals. Object.Equals has a use.

不过,如果你使用断言。等于,那么你很可能与 Assert.AreEqual 混淆它,你要停止使用。

However, if you're using Assert.Equals, then you're probably confusing it with Assert.AreEqual, and you want to stop using it.

这篇关于什么是Assert.Equals的使用情况如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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