我工作的单元测试我当前的项目并在一些奇怪的来了。在.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的使用情况如何?
发布评论