Skip to content

Steps Modules

Anna Abalmaz edited this page Nov 11, 2016 · 16 revisions

An introduction to Steps Modules.

Table of content

  1. Introducton of Steps Modules
  2. Anatomy of Steps Modules
  3. Invocation of Steps Modules

Introduction of Steps Modules

Step Module - it is an abstraction, which is represented by a class, which plays role for the set of actions, that are applied before and/or after of invocation of different steps. Here, for example, you can analyze step result and do some action based on successful step completed or not.

Anatomy of Step Module

**Step Module ** - is a class, which implements IStepModule. This interface defines

     void AfterExecution(IStep step, StepState state);

and

    void BeforeExecution(IStep step);

methods, which are core places to put logic of a step module.

See example of creation of the Step Module:

public class YourStepModule: IStepModule
{
    public void BeforeExecution(IStep step) { /// your code. }
    public void AfterExecution(IStep step, StepState state){ /// your code. }
}

Step Module may have conditions, set by attributes, which restrict appliance of Step Module to your step. For example, if you want Step Module to be applied to only exact step, you may use the attribute TargetStep:

[TargetStep(typeof(StepOnWhichStepModuleToBeAppliedFor))]

Invocation of Step Module

To make Step Module work you have to register it in the constructor of your test class. See example:

RegisterStepModule<YourStepModule>();

You can register as many Step Modules as you want. To cancel the registration you should use:

UnregisterStepModule<YourStepModule>();