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,
[NUnit.Framework.TestFixture]
class EmptyStack:
If you include setup
or teardown
blocks for a context then these generate the
special SetUp()
and TearDown()
methods expected by NUnit.
[NUnit.Framework.SetUp]
def SetUp():
your_code_here
[NUnit.Framework.TearDown]
def TearDown():
your_code_here
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
Generates:
[NUnit.Framework.Test]
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
Generates:
[NUnit.Framework.Test]
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.