Applying a behavior to all specs

Let's apply a convention that will log how long each spec takes to execute:

[SetUpFixture]
    public class Configuration : SpecsForConfiguration
    {
        public Configuration()
        {
            WhenTestingAnything().EnrichWith<LogExecutionTimeBehavior>();
        }
    }

The first part of the statement, "WhenTestingAnything()," tells SpecsFor that we're defining a convention that will apply to all specs. The second part, "EnrichWith()," defines the behavior we want to apply to our specs.

This code won't compile yet, because we haven't actually created our LogExecutionTimeBehavior class. Let's do that now!

Continue on to learn about creating behaviors.


Did this page help you?