Skip to content

StorEvil Context Classes

davidmfoley edited this page Sep 13, 2010 · 12 revisions

StorEvil instantiates classes that you create (Context Classes) in order to interpret specifications.
These Context classes are similar to Steps in Cucumber.

Your context classes must follow a few rules:

  1. Must be public and have the StoreEvil.Context attribute
  2. You must tell StorEvil the assemblies that contain your context classes using the storevil.config or a command-line switch.

for example:


[StorEvil.Context]
public class ExampleContext  {
    public void Given_some_precondition() {
    }
}

Note that the types of any return values of context method for partial matches do not necessarily need to be public:


[StorEvil.Context]
public class ExampleContext  {
    public ExampleSubContext Given_some_precondition() {
        return new ExampleSubContext();
    }
}

internal class ExampleSubContext {
   ...
}

Cleaning up: implement IDisposable

If you need to clean up some resources when a context is finished, implement IDisposable in your context class. It will be invoked when the scenario (or other lifetime, if set) is complete.

Lifetime of context classes

See: Context Lifetimes

Clone this wiki locally