Commits

Johannes Rudolph committed eb4dc7f

Comments (0)

Files changed (1)

-== About SubSpec ==
+=== About SubSpec ===
 
 SubSpec allows developers to write declarative tests operating at all layers of abstraction. SubSpec consists of a small set of primitive concepts that are highly composable. Based on the powerful xUnit testing framework, SubSpec is easy to integrate with existing testing environments.
 
 SubSpec was originally started as a demo project by Phil Haack and Brad Wilson to show how a test framework supporting the BDD inspired Specification Style can be implemented on top of the powerful xUnit .Net testing framework.
 
-The original article anouncing the project can be found [[http://haacked.com/archive/2008/08/24/introducing-subspec.aspx|here]]. Since then, SubSpec has been officially part of the [[http://xunit.codeplex.com/|xUnit Samples]] project.
+The original article anouncing the project can be found [[http://haacked.com/archive/2008/08/24/introducing-subspec.aspx|here]]. Since then, SubSpec has been officially part of the [[http://xunit.codeplex.com/|xUnit Samples]] project.
+
+=== Quickstart ===
+
+While SubSpec is inspired by the BDD methodology, it can well be used as a tool for writing declarative unit tests. A classical unit test (a Fact in xUnit) consists of three primitive operations:
+
+# Arrange the System Under Test
+# Act on the System Under Test
+# Verify the action had the desired effects
+
+A SubSpec //Specification// is constructed using the same primitives. Instead of writing a test method that //executes// a test, using SubSpec we write a method that //declares// these primitives:
+{{{
+#!csharp
+
+[Specification]
+public void PushSpecification()
+{
+	var stack = default(Stack<string>);
+	"Given a new stack".Context(() => stack = new Stack<string>());
+
+	string element = "first element";
+	"with an element pushed onto it".Do(() => stack.Push(element));
+
+	"expect the stack is not empty".Assert(() => Assert.False(stack.IsEmpty));
+	"expect the stacks Top is the pushed element".Assert(() => Assert.Equals(element, stack.Top));
+}
+}}}
+
+Because SubSpec allows you to //declare// the tests primitives instead of asking //you// to execute them, SubSpecs execution engine is free to compose them into test cases and take care of executing them correctly. More specifically, SubSpec helps you enforce the "one assert per test" rule by generating **two** tests from the previous Specification:
+
+# **Given **a new stack **with **an element pushed onto it, **expect **the stack is not empty.
+# **Given **a new stack **with **an element pushed onto it, **expect **the stacks Top is the pushed element.