Created
November 25, 2013 10:47
-
-
Save teamaton/7639546 to your computer and use it in GitHub Desktop.
Extract full test method name from currently running SpecFlow scenario
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
private static void SaveTestNameToFailedTestsFile() { | |
var scenarioDesc = ScenarioContext.Current.ScenarioInfo.Title; | |
var methodInfos = typeof (InfrastructureSteps).Assembly.GetTypes() | |
.SelectMany( | |
type => type.GetMethods() | |
.Where(m => m.GetCustomAttributes(typeof (DescriptionAttribute), false) | |
.Any(attr => ((DescriptionAttribute) attr).Description == scenarioDesc))); | |
foreach (var methodInfo in methodInfos) { | |
var fullMethodName = methodInfo.ReflectedType.FullName + "." + methodInfo.Name; | |
Log.Info("Saving current test method name: {0}", fullMethodName); | |
File.AppendAllText(_failedTestsFile, fullMethodName + Environment.NewLine); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment