public bool RunScenario(ProjectItem projectItem, IScenarioBlock currentScenario, ScenarioOutlineExamplesRow examplesRow, IGherkinFileScope fileScope, bool debug) { var line = currentScenario.KeywordLine; if (examplesRow != null && examplesRow.BlockRelativeLine >= 0) line += examplesRow.BlockRelativeLine; return RunInCurrentContext(VsxHelper.GetFileName(projectItem), debug, line); }
public bool RunScenario(ProjectItem projectItem, IScenarioBlock currentScenario, IGherkinFileScope fileScope, bool debug) { if (IsAllowDebugGeneratedFilesSet(projectItem)) return runnerGateway_CodeBehind.RunScenario(projectItem, currentScenario, fileScope, debug); return runnerGateway_TestWindowInvoke.RunScenario(projectItem, currentScenario, fileScope, debug); }
public bool RunScenario(ProjectItem projectItem, IScenarioBlock currentScenario, IGherkinFileScope fileScope, bool debug) { var testRunnerGateway = GetCurrentTestRunnerGateway(projectItem.ContainingProject); if (testRunnerGateway == null) return false; return testRunnerGateway.RunScenario(projectItem, currentScenario, fileScope, debug); }
public bool RunScenario(ProjectItem projectItem, IScenarioBlock currentScenario, IGherkinFileScope fileScope, bool debug) { if (fileScope.HeaderBlock == null) return false; //TODO: support scenario outline string path = string.Format("Feature:{0}/Scenario:{1}", Escape(fileScope.HeaderBlock.Title), Escape(currentScenario.Title)); return RunTests(projectItem.ContainingProject, "testpath:" + path, debug); }
public bool RunScenario(ProjectItem projectItem, IScenarioBlock currentScenario, IGherkinFileScope fileScope, bool debug) { if (IsAllowDebugGeneratedFilesSet(projectItem)) { return(runnerGateway_CodeBehind.RunScenario(projectItem, currentScenario, fileScope, debug)); } return(runnerGateway_TestWindowInvoke.RunScenario(projectItem, currentScenario, fileScope, debug)); }
public bool RunScenario(ProjectItem projectItem, IScenarioBlock currentScenario, ScenarioOutlineExamplesRow examplesRow, IGherkinFileScope fileScope, bool debug) { var line = currentScenario.KeywordLine; if (examplesRow != null && examplesRow.BlockRelativeLine >= 0) { line += examplesRow.BlockRelativeLine; } return(RunInCurrentContext(VsxHelper.GetFileName(projectItem), debug, line)); }
public bool RunScenario(ProjectItem projectItem, IScenarioBlock currentScenario, ScenarioOutlineExamplesRow examplesRow, IGherkinFileScope fileScope, bool debug) { var testRunnerGateway = GetCurrentTestRunnerGateway(projectItem.ContainingProject); if (testRunnerGateway == null) { return(false); } return(testRunnerGateway.RunScenario(projectItem, currentScenario, examplesRow, fileScope, debug)); }
public bool RunScenario(ProjectItem projectItem, IScenarioBlock currentScenario, ScenarioOutlineExamplesRow examplesRow, IGherkinFileScope fileScope, bool debug) { if (fileScope.HeaderBlock == null) { return(false); } //TODO: support scenario outline string path = string.Format("Feature:{0}/Scenario:{1}", Escape(fileScope.HeaderBlock.Title), Escape(currentScenario.Title)); return(RunTests(projectItem.ContainingProject, "testpath:" + path, debug)); }
public static IScenarioBlock Shift(this IScenarioBlock fileBlock, int lineShift) { if (fileBlock == null) { throw new ArgumentNullException("fileBlock"); } if (fileBlock is IScenarioOutlineBlock) { return(Shift((IScenarioOutlineBlock)fileBlock, lineShift)); } UnWrapShiftdFileBlock(ref fileBlock, ref lineShift); return(new ShiftedScenarioBlock(fileBlock, lineShift)); }
public bool RunScenario(ProjectItem projectItem, IScenarioBlock currentScenario, ScenarioOutlineExamplesRow examplesRow, IGherkinFileScope fileScope, bool debug) { if (fileScope.HeaderBlock == null) { return(false); } string escapedFeatureTitle = Escape(fileScope.HeaderBlock.Title); string scenarioPattern = currentScenario is IScenarioOutlineBlock ? string.Format("{0}, *", currentScenario.Title) : currentScenario.Title; string path = string.Format("Feature:{0}/Scenario:{1}", escapedFeatureTitle, Escape(scenarioPattern)); return(RunTests(projectItem.ContainingProject, string.Format("testpath:{0}", path), debug)); }
private int GetCodeBehindLineFromScenarioTitle(TextDocument codeBehindDoc, IScenarioBlock currentScenario) { // we look for the following pattern // c#: new TechTalk.SpecFlow.ScenarioInfo("Add two numbers... \"\\" // VB: New TechTalk.SpecFlow.ScenarioInfo("Add two numbers... ""\" var title = currentScenario.Title; var csTitleLiteral = "\"" + title.Replace(@"\", @"\\").Replace("\"", "\\\"") + "\""; var csPatternToLookFor = string.Format("new TechTalk.SpecFlow.ScenarioInfo({0}", csTitleLiteral); var vbTitleLiteral = "\"" + title.Replace("\"", "\"\"") + "\""; var vbPatternToLookFor = string.Format("New TechTalk.SpecFlow.ScenarioInfo({0}", vbTitleLiteral); return(FindPatternInDocument(codeBehindDoc, csPatternToLookFor, vbPatternToLookFor)); }
private GherkinFileScopeChange PartialParse(GherkinTextBufferChange change, IGherkinFileScope previousScope) { visualStudioTracer.Trace("Start incremental parsing", ParserTraceCategory); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); partialParseCount++; var textSnapshot = change.ResultTextSnapshot; IScenarioBlock firstAffectedScenario = GetFirstAffectedScenario(change, previousScope); VisualStudioTracer.Assert(firstAffectedScenario != null, "first affected scenario is null"); int parseStartPosition = textSnapshot.GetLineFromLineNumber(firstAffectedScenario.GetStartLine()).Start; string fileContent = textSnapshot.GetText(parseStartPosition, textSnapshot.Length - parseStartPosition); var gherkinListener = new GherkinTextBufferPartialParserListener( previousScope.GherkinDialect, textSnapshot, projectScope, previousScope, change.EndLine, change.LineCountDelta); var scanner = new GherkinScanner(previousScope.GherkinDialect, fileContent, firstAffectedScenario.GetStartLine()); IScenarioBlock firstUnchangedScenario = null; try { scanner.Scan(gherkinListener); } catch (PartialListeningDoneException partialListeningDoneException) { firstUnchangedScenario = partialListeningDoneException.FirstUnchangedScenario; } var partialResult = gherkinListener.GetResult(); var result = MergePartialResult(previousScope, partialResult, firstAffectedScenario, firstUnchangedScenario, change.LineCountDelta); stopwatch.Stop(); TraceFinishParse(stopwatch, "incremental", result); return(result); }
public bool RunScenario(ProjectItem projectItem, IScenarioBlock currentScenario, IGherkinFileScope fileScope, bool debug) { int sourceLine = currentScenario.KeywordLine + 1; // keywordline is zero-indexed return(RunFromCodeBehind(projectItem, codeBehindTextDocument => GetCodeBehindLine(codeBehindTextDocument, sourceLine, currentScenario), debug)); }
private GherkinFileScopeChange MergePartialResult(IGherkinFileScope previousScope, IGherkinFileScope partialResult, IScenarioBlock firstAffectedScenario, IScenarioBlock firstUnchangedScenario, int lineCountDelta) { Debug.Assert(partialResult.HeaderBlock == null, "Partial parse cannot re-parse header"); Debug.Assert(partialResult.BackgroundBlock == null, "Partial parse cannot re-parse background"); List <IGherkinFileBlock> changedBlocks = new List <IGherkinFileBlock>(); List <IGherkinFileBlock> shiftedBlocks = new List <IGherkinFileBlock>(); GherkinFileScope fileScope = new GherkinFileScope(previousScope.GherkinDialect, partialResult.TextSnapshot) { HeaderBlock = previousScope.HeaderBlock, BackgroundBlock = previousScope.BackgroundBlock }; // inserting the non-affected scenarios fileScope.ScenarioBlocks.AddRange(previousScope.ScenarioBlocks.TakeUntilItemExclusive(firstAffectedScenario)); //inserting partial result fileScope.ScenarioBlocks.AddRange(partialResult.ScenarioBlocks); changedBlocks.AddRange(partialResult.ScenarioBlocks); if (partialResult.InvalidFileEndingBlock != null) { VisualStudioTracer.Assert(firstUnchangedScenario == null, "first affected scenario is not null"); // the last scenario was changed, but it became invalid fileScope.InvalidFileEndingBlock = partialResult.InvalidFileEndingBlock; changedBlocks.Add(fileScope.InvalidFileEndingBlock); } if (firstUnchangedScenario != null) { Tracing.VisualStudioTracer.Assert(partialResult.InvalidFileEndingBlock == null, "there is an invalid file ending block"); // inserting the non-effected scenarios at the end var shiftedScenarioBlocks = previousScope.ScenarioBlocks.SkipFromItemInclusive(firstUnchangedScenario) .Select(scenario => scenario.Shift(lineCountDelta)).ToArray(); fileScope.ScenarioBlocks.AddRange(shiftedScenarioBlocks); shiftedBlocks.AddRange(shiftedScenarioBlocks); if (previousScope.InvalidFileEndingBlock != null) { fileScope.InvalidFileEndingBlock = previousScope.InvalidFileEndingBlock.Shift(lineCountDelta); shiftedBlocks.Add(fileScope.InvalidFileEndingBlock); } } return(new GherkinFileScopeChange(fileScope, false, false, changedBlocks, shiftedBlocks)); }
public bool RunScenario(ProjectItem projectItem, IScenarioBlock currentScenario, IGherkinFileScope fileScope, bool debug) { int sourceLine = currentScenario.KeywordLine + 1; // keywordline is zero-indexed return RunFromCodeBehind(projectItem, codeBehindTextDocument => GetCodeBehindLine(codeBehindTextDocument, sourceLine), debug); }
private GherkinFileScopeChange MergePartialResult(IGherkinFileScope previousScope, IGherkinFileScope partialResult, IScenarioBlock firstAffectedScenario, IScenarioBlock firstUnchangedScenario, int lineCountDelta) { Debug.Assert(partialResult.HeaderBlock == null, "Partial parse cannot re-parse header"); Debug.Assert(partialResult.BackgroundBlock == null, "Partial parse cannot re-parse background"); List<IGherkinFileBlock> changedBlocks = new List<IGherkinFileBlock>(); List<IGherkinFileBlock> shiftedBlocks = new List<IGherkinFileBlock>(); GherkinFileScope fileScope = new GherkinFileScope(previousScope.GherkinDialect, partialResult.TextSnapshot) { HeaderBlock = previousScope.HeaderBlock, BackgroundBlock = previousScope.BackgroundBlock }; // inserting the non-affected scenarios fileScope.ScenarioBlocks.AddRange(previousScope.ScenarioBlocks.TakeUntilItemExclusive(firstAffectedScenario)); //inserting partial result fileScope.ScenarioBlocks.AddRange(partialResult.ScenarioBlocks); changedBlocks.AddRange(partialResult.ScenarioBlocks); if (partialResult.InvalidFileEndingBlock != null) { Debug.Assert(firstUnchangedScenario == null); // the last scenario was changed, but it became invalid fileScope.InvalidFileEndingBlock = partialResult.InvalidFileEndingBlock; changedBlocks.Add(fileScope.InvalidFileEndingBlock); } if (firstUnchangedScenario != null) { Debug.Assert(partialResult.InvalidFileEndingBlock == null); // inserting the non-effected scenarios at the end var shiftedScenarioBlocks = previousScope.ScenarioBlocks.SkipFromItemInclusive(firstUnchangedScenario) .Select(scenario => scenario.Shift(lineCountDelta)).ToArray(); fileScope.ScenarioBlocks.AddRange(shiftedScenarioBlocks); shiftedBlocks.AddRange(shiftedScenarioBlocks); if (previousScope.InvalidFileEndingBlock != null) { fileScope.InvalidFileEndingBlock = previousScope.InvalidFileEndingBlock.Shift(lineCountDelta); shiftedBlocks.Add(fileScope.InvalidFileEndingBlock); } } return new GherkinFileScopeChange(fileScope, false, false, changedBlocks, shiftedBlocks); }
protected virtual int GetCodeBehindLine(TextDocument codeBehindDoc, int sourceLine, IScenarioBlock currentScenario) { int result = GetCodeBehindLineFromLinePragmas(codeBehindDoc, sourceLine); if (result > 0 || currentScenario == null) { return(result); } return(GetCodeBehindLineFromScenarioTitle(codeBehindDoc, currentScenario)); }
public bool RunScenario(ProjectItem projectItem, IScenarioBlock currentScenario, IGherkinFileScope fileScope, bool debug) { return(RunInCurrentContext(VsxHelper.GetFileName(projectItem), debug, currentScenario.KeywordLine)); }
public PartialListeningDoneException(IScenarioBlock firstUnchangedScenario) { FirstUnchangedScenario = firstUnchangedScenario; }
public bool RunScenario(ProjectItem projectItem, IScenarioBlock currentScenario, IGherkinFileScope fileScope, bool debug) { return RunInCurrentContext(VsxHelper.GetFileName(projectItem), debug, currentScenario.KeywordLine); }
protected virtual int GetCodeBehindLine(TextDocument codeBehindDoc, int sourceLine, IScenarioBlock currentScenario) { int result = GetCodeBehindLineFromLinePragmas(codeBehindDoc, sourceLine); if (result > 0 || currentScenario == null) return result; return GetCodeBehindLineFromScenarioTitle(codeBehindDoc, currentScenario); }
private int GetCodeBehindLineFromScenarioTitle(TextDocument codeBehindDoc, IScenarioBlock currentScenario) { // we look for the following pattern // c#: new TechTalk.SpecFlow.ScenarioInfo("Add two numbers... \"\\" // VB: New TechTalk.SpecFlow.ScenarioInfo("Add two numbers... ""\" var title = currentScenario.Title; var csTitleLiteral = "\"" + title.Replace(@"\", @"\\").Replace("\"", "\\\"") + "\""; var csPatternToLookFor = string.Format("new TechTalk.SpecFlow.ScenarioInfo({0}", csTitleLiteral); var vbTitleLiteral = "\"" + title.Replace("\"", "\"\"") + "\""; var vbPatternToLookFor = string.Format("New TechTalk.SpecFlow.ScenarioInfo({0}", vbTitleLiteral); return FindPatternInDocument(codeBehindDoc, csPatternToLookFor, vbPatternToLookFor); }