Pex - Automated Whitebox Testing for .NET : Cheat Page

Cheat Page

important attributes in Pex: Print this page!

Getting Started

Add Pex reference Microsoft.Pex.Framework.dll
Bind test project [assembly: PexAssemblyUnderTest("UnderTest")]

Custom Attributes

PexClassAttribute marks a type containing PUT
PexMethodAttribute marks a PUT
PexAssumeNotNullAttribute marks a non-null parameter

using Microsoft.Pex.Framework;
[..., PexClass(typeof(Foo))]
public partial class FooTest {
    public void Bar([PexAssumeNotNull]Foo target, int i) {

Static Helpers

PexAssume evaluates assumptions (input filtering)
PexAssert evaluates assertions
PexChoose generates new choices (additional inputs)
PexObserve logs live values to the report and/or generated tests

void StaticHelpers(Foo target){
    int i = PexChoose.Value<int>("i");
    string result = target.Bar(i);
    PexObserve.ValueForViewing<string>("result", result);


PexAssemblyUnderTestAttribute binds a test project to a project
PexInstrumentAssemblyAttribute specifies to instrument an assembly

[assembly: PexAssemblyUnderTest("MyAssembly")] // also instruments "MyAssembly"
[assembly: PexInstrumentAssembly("Lib")]

(c) Microsoft Corporation. All rights reserved. pex Wiki Documentation 0.93.50813.0