Skip to content

Commit

Permalink
Add comments around the methods being overridden and why feature tags…
Browse files Browse the repository at this point in the history
… are already processed before we pick them up in SetTestMethodCategories
  • Loading branch information
JoshKeegan committed Feb 26, 2022
1 parent d4c2bf1 commit 7c02c0b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/xRetry.SpecFlow/TestGeneratorProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public TestGeneratorProvider(CodeDomHelper codeDomHelper, ProjectSettings projec
this.retryTagParser = retryTagParser;
}

// Called for scenario outlines, even when it has no tags.
// We don't yet have access to tags against the scenario at this point, but can handle feature tags now.
public override void SetRowTest(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, string scenarioTitle)
{
base.SetRowTest(generationContext, testMethod, scenarioTitle);
Expand All @@ -33,6 +35,8 @@ public override void SetRowTest(TestClassGenerationContext generationContext, Co
applyRetry(featureTags, Enumerable.Empty<string>(), testMethod);
}

// Called for scenarios, even when it has no tags.
// We don't yet have access to tags against the scenario at this point, but can handle feature tags now.
public override void SetTestMethod(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, string friendlyTestName)
{
base.SetTestMethod(generationContext, testMethod, friendlyTestName);
Expand All @@ -42,6 +46,7 @@ public override void SetTestMethod(TestClassGenerationContext generationContext,
applyRetry(featureTags, Enumerable.Empty<string>(), testMethod);
}

// Called for both scenarios & scenario outlines, but only if it has tags
public override void SetTestMethodCategories(TestClassGenerationContext generationContext,
CodeMemberMethod testMethod, IEnumerable<string> scenarioCategories)
{
Expand All @@ -50,6 +55,7 @@ public override void SetTestMethodCategories(TestClassGenerationContext generati

base.SetTestMethodCategories(generationContext, testMethod, scenarioCategories);

// Feature tags will have already been processed in one of the methods above, which are executed before this
IEnumerable<string> featureTags = generationContext.Feature.Tags.Select(t => stripLeadingAtSign(t.Name));
applyRetry((string[]) scenarioCategories, featureTags, testMethod);
}
Expand Down

0 comments on commit 7c02c0b

Please sign in to comment.