Search code examples
pextestcase

How to enrich the test cases generated by PEX?


Here is my Q: I've got to test a method in concatenating three short lists into a longer one. And i (pex)assumed that any of the short lists is not null(the sentences are listed below).

PexAssume.IsTrue(third != (IList<int>)null, "third");
PexAssume.IsTrue(first != (IList<int>)null, "first");
PexAssume.IsTrue(second != (IList<int>)null, "second");

But the test was carried on like this: the test cases generated by pex are all lists of zeros. This is an example: first {0,0} {0} {0}

second {0} {0,0} {0}

third {0,0} {0} {0,0}

result {0,0,0,0,0} {0,0,0,0} {0,0,0,0}

And here is my question: How to set up assumptions to enrich the test cases generated by PEX, so that there's won't be so many 0's?

Thanks!


Solution

  • Pex generates values based on what's needed to fully test a function. The fact that it's generating Lists of 0's just means that the particular values within the Lists doesn't matter for your function. You could add some if statements in your function involving the values within the Lists to force Pex to generate Lists that aren't just 0's but you really shouldn't.

    TL;DR Don't worry about it, the 0's don't matter in your test.