The assertEquals statement is widely used for testing code. It basically takes in two arguments—an expected value and an actual value—with an optional third argument message. If the expected value matches the actual value, the assertEquals passes—otherwise, it fails.
Using assertEquals with primitive types is straightforward, but if you want to use it with a custom object, you'll have to do a little more work. For example, the following assertEquals will not pass:
assertEquals(MyObj("abc"),MyObj("abc"))
In this recipe, we will learn how to write assertEquals statements.