Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the usage of Assert.Equals? [closed]

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?

like image 264
actkatiemacias Avatar asked Apr 01 '13 18:04

actkatiemacias


People also ask

What is the purpose of assert are equals?

AreEqual(Object, Object, String)Tests whether the specified objects are equal and throws an exception if the two objects are not equal.

What does assert equal return?

assertEqual() in Python is a unittest library function that is used in unit testing to check the equality of two values. This function will take three parameters as input and return a boolean value depending upon the assert condition. If both input values are equal assertEqual() will return true else return false.

What is the purpose of assert array equals message AB?

7. What is the purpose of assertArrayEquals(“message”, A, B)? Explanation: Asserts the equality of the A and B arrays.

What does assert assertTrue do?

assertTrue is used to verify if a given Boolean condition is true. This assertion returns true if the specified condition passes, if not, then an assertion error is thrown.


1 Answers

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


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

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

like image 175
John Saunders Avatar answered Oct 15 '22 15:10

John Saunders