-
Notifications
You must be signed in to change notification settings - Fork 0
Defining a custom step method
Michael W Powell edited this page Dec 8, 2020
·
1 revision
If the x
method is not to your taste, it is trivial to define your own synonym. For instance,
public static class MyExtensions
{
public static IStepBuilder o(this string text, Action body) => text.x(body);
public static IStepBuilder ʃ(this string text, Action body) => text.x(body);
public static IStepBuilder σʃσ(this string text, Action body) => text.x(body);
public static IStepBuilder 梟(this string text, Action body) => text.x(body);
public static IStepBuilder χ(this string text, Action body) => text.x(body);
}
Note that to support object disposal and async steps you need to provide overloads of your custom step method which accept Action<IStepContext>
, Func<Task>
and Func<IStepContext, Task>
. For example, the full set of custom step methods for o
would be:
public static class MyExtensions
{
public static IStepBuilder o(this string text, Action body) => text.x(body);
public static IStepBuilder o(this string text, Action<IStepContext> body) => text.x(body);
public static IStepBuilder o(this string text, Func<Task> body) => text.x(body);
public static IStepBuilder o(this string text, Func<IStepContext, Task> body) => text.x(body);
}
- Home
- Quick start
-
Documentation
- Writing scenarios
- Running scenarios
- Package dependencies
- Debugging scenarios
- Assertions
- Step names
- Debugging Scenarios with examples
- Background methods
- TearDown methods
- Async steps
- Object disposal
- Rollback
- Skipping steps and scenarios
- Step metadata
- Continuing on failure
- Step filters
- Changes in xBehave.net version 2.0
- Changes since deriving from xBehave.net
- Extending xWellBehaved.net
- FAQ
- Known Issues
- Contributions