I am trying to write a JUnit Test Case for the below Java Code:
private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof Crop))
return false;
Crop other = (Crop) obj;
if (obj == null) return false;
if (this == obj) return true;
if (__equalsCalc != null) {
return (__equalsCalc == obj);
}
}
The Test case i wote is below:
public void testCrop() {
Crop cp = new Crop();
Object obj = false;
cp.equals(obj);
assertSame(obj instanceof Crop, false);
}
public void testCrop1() {
Crop other = (Crop) obj;
// assertSame(other.equals(obj), true);
assertEquals(obj, other);
}
The test case for instanceof
is working fine, but while checking if(obj == null) return false;
the test case is failing: