assertSame() method
This lesson demonstrates how to use assertSame method in JUnit 5 to assert test conditions.
We'll cover the following
assertSame() method
Assertions API provide static assertSame()
method. This method helps us in validating that expected
and actual
refer to the exact same object. JUnit uses ==
operator to perform this assert.
- If the actual and expected value refers to the same object then the test case will pass.
- If the actual and expected value does not refer to the same object then the test case will fail.
There are basically three useful overloaded methods for assertSame:-
Get hands-on with 1400+ tech skills courses.