Open
Description
Description
Suggestion to make arrays with different values more prioritized.
Expected behavior
Arrays with different values inside should be generated if and only if values equality is not included in path constraints.
Environment
For both IntelliJ Plugin and CLI
Context
Now equal values are generated for successful execution of Sort::swap
The coverage is reached. But it is not really informative for such a method.
Different values are generated only when such an assumption is explicitly added inside the method.
Method under test:
public void swap(long[] array, int i, int j) {
UtMock.assume(array[i] != array[j]);
long tmp = array[i];
array[i] = array[j];
array[j] = tmp;
}
Compare successful test being generated.
Without assume:
public void testSwap() {
Sort sort = new Sort();
long[] array = {-255L, -255L};
sort.swap(array, 0, 1);
}
With assume:
public void testSwap_UtMockAssume() {
Sort sort = new Sort();
long[] array = {5L, 4L};
sort.swap(array, 0, 1);
long finalArray0 = array[0];
long finalArray1 = array[1];
assertEquals(4L, finalArray0);
assertEquals(5L, finalArray1);
}
Autotest on this (to be added in SortTest.kt):
@Test
fun testSwapMutation() {
withoutConcrete {
checkParamsMutations(
Sort::swap,
ignoreExecutionsNumber,
{ a, i, j, a1, _, _ -> a != null && i in a.indices && j in a.indices && !a1.contentEquals(a) }
, coverage = atLeast(percents = 95)
)
}
}
Metadata
Metadata
Assignees
Type
Projects
Status
Todo