Auto-generation of .NET unit tests

Phobis picture Phobis · Sep 27, 2008 · Viewed 37.9k times · Source

Is there such a thing as unit test generation? If so...

...does it work well?

...What are the auto generation solutions that are available for .NET?

...are there examples of using a technology like this?

...is this only good for certain types of applications, or could it be used to replace all manually written unit testing?

Answer

Paul Batum picture Paul Batum · Sep 27, 2008

Take a look at Pex. Its a Microsoft Research project. From the website:

Pex generates Unit Tests from hand-written Parameterized Unit Tests through Automated Exploratory Testing based on Dynamic Symbolic Execution.

UPDATE for 2019:

As mentioned in the comments, Pex is now called IntelliTest and is a feature of Visual Studio Enterprise Edition. It supports emitting tests in MSTest, MSTest V2, NUnit, and xUnit format and it is extensible so you can use it with other unit test frameworks.

But be aware of the following caveats:

  • Supports only C# code that targets the .NET Framework.
  • Does not support x64 configurations.
  • Available in Visual Studio Enterprise Edition only