assertNotSame() method
This lesson demonstrates how to use assertNotSame method in JUnit 5 to assert test conditions.
We'll cover the following
assertNotSame() method
Assertions API provide static assertNotSame()
method. This method helps us in validating that expected
and actual
do not 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 fail.
- If the actual and expected value does not refer to the same object then the test case will pass.
There are basically three useful overloaded methods for assertNotSame:-
Get hands-on with 1400+ tech skills courses.