Closed ParagRaut closed 5 years ago
private static ExtentTest featureName;
private static ExtentTest scenario;
[BeforeFeature]
public static void BeforeFeature()
{
featureName = extent.CreateTest<Feature>(FeatureContext.Current.FeatureInfo.Title);
}
[AfterStep]
public void InsertReportingSteps()
{
try
{
var stepType = ScenarioStepContext.Current.StepInfo.StepDefinitionType.ToString();
if (ScenarioContext.Current.TestError == null)
{
if (stepType == "Given")
scenario.CreateNode<Given>(ScenarioStepContext.Current.StepInfo.Text);
else if (stepType == "When")
scenario.CreateNode<When>(ScenarioStepContext.Current.StepInfo.Text);
else if (stepType == "Then")
scenario.CreateNode<Then>(ScenarioStepContext.Current.StepInfo.Text);
else if (stepType == "And")
scenario.CreateNode<And>(ScenarioStepContext.Current.StepInfo.Text);
}
See above example! are you using correct annotation and Feature/Scenario terminology?
@rudreshtrivedi in above example you're not initializing scenario, i.e. private static ExtentTest scenario;
I use following before initializing the test,
FeatureName = ExtentReports.CreateTest
One thing I noticed is I put both statement in before scenario tag, which I can correct now
Thanks it solved my issue now I do this:
[BeforeFeature]
protected static void InitializeCurrentFeatureContext()
{
if (IsExtentReportsEnabled)
{
ExtentReporter.InitializeCurrentFeatureContext();
}
}
[BeforeScenario]
protected static void InitializeScenarioContext()
{
if (IsExtentReportsEnabled)
{
ExtentReporter.InitializeCurrentScenarioContext();
}
}
Which is basically doing both steps separately in different tags, thanks again
Welcome
I have multiple Features which have multiple number of scenario in each of them. In reports I see # of Feature is equal to # of Scenarios which I know is wrong. Below is screenshot:
I'm using BDD approach and these methods to create nodes:
Can you tell me if I'm doing something wrong ?