Skip to content

Instantly share code, notes, and snippets.

@TomKearney
Created June 27, 2012 12:52
Show Gist options
  • Select an option

  • Save TomKearney/3003903 to your computer and use it in GitHub Desktop.

Select an option

Save TomKearney/3003903 to your computer and use it in GitHub Desktop.
Step file to invoke existing scenarios using naming convention.
[Binding]
public class ScenarioInvoker_Steps
{
[Given(@"Successfully run scenario (.*)")]
public void GivenSuccessfullyRunScenario(String featureAndScenarioName)
{
var parts = featureAndScenarioName.Split(new string[] {"S_"}, StringSplitOptions.RemoveEmptyEntries);
if(parts.Length != 2)
throw new ArgumentException("Invalid scenario reference string \"{0}\". Expecting string to be in the format F_N Feature Name S_N Scenario Name");
String featureName = parts[0];
String scenarioName = "S_" + parts[1];
var feature = FeatureLocator.FindFeatureById(featureName);
if(feature == null)
throw new ArgumentException("Unable to find feature by id \"{0}\"".FormatWith(featureName));
feature.SetUp();
var scenario = feature.FindScenarioForId(scenarioName);
if(scenario == null)
throw new ArgumentException("Unable to find scenario by id \"{0}\"".FormatWith(scenarioName));
scenario.Run();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment