Created
June 27, 2012 12:52
-
-
Save TomKearney/3003903 to your computer and use it in GitHub Desktop.
Step file to invoke existing scenarios using naming convention.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [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