什么是Assert.Equals的使用情况如何?

编程入门 行业动态 更新时间:2024-10-08 20:29:40
本文介绍了什么是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的使用情况如何?

本文发布于:2023-11-23 07:05:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620547.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:情况   Assert   Equals

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!