Sunday, May 27, 2007

.Net 2.0 has been out for a while and it seems that 'generics' have not made it into unit test frameworks (that I know of). When I write unit tests for generics, I don't want to have to instantiate them!

For example, if I have an generic interface,

interface IFoo<T> {...}

then I'd really like to write this kind of test and let the test framework figure out an interresting instantiation (i.e. choice of T):

[Test]
public void Test<T>(IFoo<T> foo) { ... }

In the example above, System.Object can be trivially used to instantiate IFoo<T>. Of course, things get more interresting when mixing type argument, method argument and constraints :)

interface IFoo<T>
{
    R Bar<R>(T t)
     where R : IEnumerable<T>
}

In Pex, we've started to look at this problem... stay tuned.

Friday, June 01, 2007 9:26:39 AM UTC
Cool, I'm really looking forward to Pex. This something that will be available post-Orcas?

p.s. your link to pex is research.microsoft.com/owa, which appears wrong. Since o, w, and a are about 1 keyboard letter way from p, e, and x, I assume it was a typo. :-)
Saturday, June 02, 2007 12:44:50 PM UTC
Thanks I fixed the link (http://research.microsoft.com/pex)...

We working hard a ways to get Pex out in the wild. Currently, I cannot give you timeline when this will happen (unfortunately).
Sunday, June 03, 2007 1:01:47 AM UTC
Cool, thanks Jonathan. I'm glad you guys are looking to put this out in the wild. You know, even some preview releases on MS Research would absolutely rock.

I'd love to play with this; seems like it would save us hours every day as we manually are churning out unit tests.
Comments are closed.