How to have Pex generate NUnit, MbUnit and XUnit tests

By default, Pex will generate MSTEST tests, however that doesn’t mean you are constrained to using MSTEST for your project. The Pex Extensions project on CodePlex has a set of extensions which allows Pex to generate code for the three main test frameworks. I’ve just committed some changes to make the code work against the newly released Pex 0.6.  In order to generate tests for a particular framework, you need to follow these instructions.

XUnit

image1) Reference Pex.xUnit.dll

2) In your test project’s AssemblyInfo.cs. Add the attribute – [assembly: Pex.Xunit.PexXunitPackage]

3) Pex will now start generating xUnit tests.

NUnit

image 1) Reference Pex.NUnit.dll

2) In your test project’s AssemblyInfo.cs. Add the attribute – [assembly: Pex.NUnit.PexNUnitPackage]

3) Pex will now start generating NUnit tests.

MbUnit v3

1) Reference Pex.MbUnit.dll

2) In your test project’s AssemblyInfo.cs. Add the attribute – [assembly: Pex.MbUnit.PexMbUnitPackage]

3) Pex will now start generating MbUnit v3 tests. A MbUnit extension is also included within the GallioMbUnit package.

Note: At the moment, you need to download the source code from codeplex and compile the binaries yourself, there is a single solution file which will build everything.

image

You also need to ensure both the extensions and your test project are built against the same version of the unit testing framework, otherwise there will be a type mismatch and Pex won’t be able to generate any tests.

Technorati Tags: , , ,

4 thoughts on “How to have Pex generate NUnit, MbUnit and XUnit tests”

  1. Pex would be able to generate 2.5 tests, however you will have to do some additional work. The Pex Extensions project will help. The binary releases are built against 2.4.8, however you can manually rebuild the project for 2.5 and then Pex will be able to generate code.

    Read this wiki page on how to do it:
    http://www.codeplex.com/Pex/Wiki/View.aspx?title=build&referringTitle=Home

    Hope this helps, if you want to know anything else please let me know.

    Ben

Leave a Reply

Your email address will not be published. Required fields are marked *