locked
Canonical generic type for initializers RRS feed

  • Question

  • I noticed that for generic types I have tested with Pex, given a class Foo<T>, Pex only creates Foo<Int32>.  Wouldn’t it be more exhaustive to use one canonical value type (Int32 is fine) and one canonical reference type (perhaps String)?  Or does Pex, in fact, use a reference type if, after inspecting the code, it sees anything that may cause it to think that the behavior would be different for ref versus val types?
    Wednesday, May 26, 2010 6:59 PM

Answers

  • Pex does not reason about generic type parameters, so Pex will not use different type instantiations if that would make a difference to the code under test.

    What you can do is write a generic parameterized unit test, and then use the [PexGenericArguments(...)] attribute to tell Pex what types to use to instantiate the generic parameterized unit test.


    Nikolai Tillmann
    Wednesday, May 26, 2010 10:37 PM