Here I am going to explain the issue by an example. The original question presents the problem more abstractly. No need to read it though.
Update: Question as an example
Lets say we have implemented this buggy function for finding the min of int[]:
public int MyMin(int[] data)
{
int min = 1000;
for (int i = 1; i < data.Length; i++)
{
if (data[i] < min)
{
min = data[i];
}
}
return min;
}
Running Intellitest on this function gives us:
Note for test #4 and #6 the function is not calculating the min value correctly due to its buggy implementation. However, these tests are passing which is not desired.
Intellitest cannot magically determine our intended behavior of MyMin
and craft the test to fail on these inputs. However, it would be very nice if we could manually specify the desired result for these tests.
@michał-komorowski's solution is feasible, but for each test case I have to repeat its input in terms of PexAssume
s. Is there a more elegent/clean way to specify the desired output for the test inputs?
Original Question
Intelitest generates a parameterized test that is modifiable and general/global assertions can be added there. It also generates the minimum number of inputs that maximize the code coverage. Intellitest stores the inputs as individual unit tests, each one calling the parameterized test with a crafted input.
I am looking for a way to add assertion per each input.
As each input is stored as a unit test function in a .g.cs file, the assertion can be added there. The problem is that these functions are not supposed to be customized by the user since they will get overwritten by Intellitest in its subsequent runs.
What is the recommended way of adding assertions for each unit test?