Skip to content

Instantly share code, notes, and snippets.

@laribee
Created November 6, 2017 20:24
Show Gist options
  • Save laribee/0e721f124c4533b93929eb0c90675fa3 to your computer and use it in GitHub Desktop.
Save laribee/0e721f124c4533b93929eb0c90675fa3 to your computer and use it in GitHub Desktop.
Test-per-scenario with SpecFlow
Feature: Example
Can we bypass step definitions and use a single test
fixture instead? Yes we can!
Scenario: Spike
Now I can explain my scenario and examples
outside of the somewhat restrictive GWT-type
language.
[Binding]
[Scope(Feature = "Example", Scenario = "Spike")]
public class ExampleSteps : TestPerScenario
{
protected override void Scenario()
{
// Given OR Arrange
// When OR Act
// Then OR Assert
Assert.True(false);
}
}
public abstract class TestPerScenario
{
[StepDefinition(@"(.*)")]
public void AllSteps(string stepName)
{
// maybe do something with stepName
}
[AfterScenario()]
public virtual void Hook()
{
Scenario();
}
protected abstract void Scenario();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment