NUnit Integration

Specs written using Specter generate (when compiled as a library) a normal NUnit testfixture DLL. The assembly can be loaded and tested by NUnit.
This page provides an overview of the kind of code generated at compile time by the Specter macros.

Each context will be a class in the assembly. The name of the class is derived from the textual description you give the context. In addition, the NUnit TestFixture attribute is applied so that the class will be picked up for testing.

For example,
context "Empty stack":
will transform into,
class EmptyStack:

If you include setup or teardown blocks for a context then these generate the special SetUp() and TearDown() methods expected by NUnit.

def SetUp():
def TearDown():

A specify block will generate NUnit test methods. If you have given a textual description of the assertion then that is used to create the method name. The description is also reported by NUnit upon failure of a test.

specify "Stack count is zero":
    stack.Count.Must == 0


def StackCountIsZero():
    Int32MustModule.Must(stack.Count, "Stack count is zero").Equal(0)

If you use the single line form of the specify macro then Specter will extract the method name and assertion description from the line of code itself.

specify stack.Count.Must == 0


def StackCountMustEqual0():
    Int32MustModule.Must(stack.Count, "Stack count must equal 0").Equal(0)

Note that the Must methods actually call NUnit's Assert internally.

Want more ?

Look at the other documentation links on the homepage.