-
Notifications
You must be signed in to change notification settings - Fork 0
TearDowns
Michael W Powell edited this page Dec 8, 2020
·
1 revision
xWellBehaved.net now also allows the addition of tear down steps, exactly converse to the Background methods.
Consider that the perspicuous Calculator
has the added responsibility of requiring a CoolDown before finally being disposed of. But let us also consider that these are best managed during separately derived test classes.
public abstract class CalculatorFeature
{
protected Calculator Instance { get; private set; }
[Background]
public void Background()
{
"Given a calculator".x(() => this.Instance = new Calculator());
}
[TearDown]
public void TearDown() // which may be named anything
{
"Dispose of the calculator".x(() => this.Instance.AssertNotNull()?.Dispose());
}
[Scenario]
public void Feature()
{
"Just the facts ma'am, we cool".x(() => ...);
}
}
public class CalculatorCoolDownFeature : CalculatorFeature
{
[TearDown]
public void CoolDownTearDown()
{
"Cool it, calculator".x(() => this.Instance.AssertNotNull()?.CoolDown());
}
[Scenario]
public void SomeUltraHotFeature()
{
"Can we ask you to cooldown after this one".x(() => ...);
}
}
In the above example, xWellBehaved.net will ensure that CoolDownTearDown
occurs before TearDown
, in the order opposite that of its declaration.
- 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