In order to reduce code duplication I would like to generate unit tests programatically from various sources. One simple way I could think of was to generate a whole bunch of delegates from within a method that parses some configuration information and tags all those delegates with the [TestMethod]
attribute which are then run by the visual studio test framework.
My motivation is to use as much of the visual studio's test reporting facilities as possible because I could write my own reporting layer for the tests by using some of C#'s reflection facilities but I rather not. My solution seems pretty elegant and simple but I can't get visual studio's test framework to understand what exactly I'm trying to do so does anyone know how to go about doing what I would like?
You may want to consider Pex (and possibly Moles for legacy code) from Microsoft Research. Pex is a research project that automatically generates unit tests with high code coverage, and supposedly picks interesting input and outputs for the tests. I guess there's some intelligence there. :)
I have not personally used it, but I have heard from some peers that Pex and Moles is pretty interesting and has helped them out. May be worth a look.
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With