This project is read-only.

Writing your own Extensions

One of the core design goals was to allow TripleA to be easily extended so that it can "reach out" to all parts of your system (eg: Windows Service manipulation) and automate them to arrange the state as required to execute a meaningful test. I have written the steps that ship with TripleA as extensions to dog-food this mechanism and to provide real examples for building your own. I hope to develop the set of extensions over time as I encounter new "automation/assertion" points and would welcome a "contrib" project to provide additional components.


1. Write a new IPipelineStep<T> component. This is a plugin to the pipeline that actually does the work - make it do whatever you want, wrap/call other existing steps etc.
  • Create a new class and make it inherit from StepBase<T>, this is a base class that helps build a step, alternatively implement IPipelineStep<T> for full control.
  • Add the code you need the step to perform to the Execute() method.
public class MyAwesomeStep<T> : StepBase<T>
    where T: Context
    public MyAwesomeStep (string someParam, int AnotherParam)
           // set private vars from ctor params

    public override void Execute(T context)
          // do something awesome here, arrange or assert something!
2. Write an extension method to IPipelineConfig<T>. This is how we connect your new plugin to the fluent interface for easy configuration. This method should create an instance of your new IPipelineStep<T>, pass through any parameters it takes and finally add it to the pipeline.

public static class MyExtensions
    public static IPipelineConfig<T> MyAwesomeExtension(this IPipelineConfig<T> config, string someParam, int anotherParam)
          config.RunStep(new MyAwesomeStep(someParam, anotherParam));
          return config;
3. Your extension method will appear as a new fluent method on the "config" Action parameter available in the Session.Setup(...) entry point, pass in the parameters and that's it - your step will be added to the pipeline and executed!
// NUnit test
public void AnotherTest()
    var session = Session.Setup<TestContext>(
        config =>
             config.MyAwesomeExtension("SomeParam", 42)
                 //. other extension methods available on the fluent interface;

        var result = session.Execute(new TestContext());

        // using FluentAsserts nuget package

Last edited Mar 20, 2013 at 6:14 PM by jimbobdog, version 8


No comments yet.