Closed
Description
Description
Consider the following class
public class CashCoder {
private int[] value /*= new int[0]*/;
public CashCoder() { }
public CashCoder(int[] value) {
this.value = value;
}
public int cashCode() {
int result = 0;
for (int i : value) {
result = 31 * result + i;
}
if (result == 42 && value.length > 1 && value[0] > 0) throw new RuntimeException("It's forty two!");
return result;
}
}
Tests, generated for cashCode
method, should use constructor, but creating an instance with reflection is actually called
Expected behavior
Tests are something like this:
@Test
@DisplayName("cashCode: result == 42 : False -> return result")
public void testCashCode_ResultNotEquals42() {
int[] intArray = {};
CashCoder cashCoder = new CashCoder(intArray);
int actual = cashCoder.cashCode();
assertEquals(0, actual);
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done