Closed anunay1 closed 4 years ago
I same issue , execute extent.flush() not exception on window local machine but throw same exception on mac - jenkins
Can you share the step which causes this exception?
Please use the .Net Standard release, version 4.1.0-alpha. This should be resolved.
Please use the .Net Standard release, version 4.1.0-alpha. This should be resolved.
Yes, Thank you :))
Is there a better answer here? I am working an API contract at Microsoft and we are wanting to use Extent Reports to get HTML for our integration tests in spec Flow but currently we are using .NET Core 2.2 which is not in LTS. We have a story in the backlog to decide on .NET Core 2.1 or 3.1 since they are LTS but in the meantime the exception in the Flush() is a major blocker.
@ScottyMac52 What version are you using? 4.1.0-beta1? This issue was resolved in this version's alpha, I just haven't had a chance to complete the release version, but will be focusing on .NET as Java's v5 was released today.
Hi @anshooarora ,
I am using Extent reporting 4.1.0 version with Specflow + C# + Visual Studio. Everything is working as expected on windows. But when I ran the same configuration code on MAC, Extent reporting is throwing exceptational when Flush(); functions gets executed. It is happening only when there is assertion failure in the Tests. Report is getting generated as expected when Test case passed.
.Net 6.0(Windows), .Net core 3.1(Target framework .Net 6.0) on MAC Visual Studio 2022(Windows) Visual Studio 2019(Mac) Extent Reporting 4.1.0 both on windows and Mac
Issue is only with MAC Error/exceptational: RazorEngine.Templating.TemplateCompilationException " Error while creating the template".
Could you please help me to resolve the issue?
@shubautomation
Can you provide a sample code where the issue occurs?
Hi @namilkimfree
I am not sure if you re looking for the below code: Kindly let me know if you need any other thing: .Net 6.0(Windows), .Net core 3.1(Target framework .Net 6.0) on MAC Visual Studio 2022(Windows) Visual Studio 2019(Mac) Extent Reporting 4.1.0 both on windows and Mac
Issue: Is happening only on Mac OS. Not sure problem is with MAC OS or Extent reporting plugin. Please help, it is blocker for me.
In Hooks.cs :
[AfterTestRun] public static void AfterTestRun() { _extentReports.Flush();
}
Feature: @Login Scenario: Login page with valid username and password
Given user is on xyz website When user login with "abc" username and "xyz*" password Then user should be on "Home" page And user logout from the application
Step File: [Given(@"user is on xyz website")] public void GivenUserIsOnXyzWebsite() { Launch();
}
[When(@"user login with ""([^""])"" username and ""([^""])"" password")] public void WhenUserLoginWithUsernameAndPassword(string username, string password) { loginPage.Login(username, password); }
[Then(@"user should be on ""([^""]*)"" page")] public void ThenUserShouldBeOnPage(string page) {
commonPage.ValidatePage(page);
}
In Login page: public void ValidatePage(page){
Assert.AreEqual("Home", page);
}
So when ever assertion failed, lets say "Home is not equal to Home" then execute _extentReports.Flush(); in AfterTestRUn function it throws below error
RazorEngine.Templating.TemplateCompilationException has been thrown
"Errors while compiling a Template.\nPlease try the following to solve the situation:\n If the problem is about missing/invalid references or multiple defines either try to load \n the missing references manually (in the compiling appdomain!) or\n Specify your references manually by providing your own IReferenceResolver implementation.\n See https://antaris.github.io/RazorEngine/ReferenceResolver.html for details.\n Currently all references have to be available as files!\n If you get 'class' does not contain a definition for 'member': \n try another modelType (for example 'null' to make the model dynamic).\n NOTE: You CANNOT use typeof(dynamic) to make the model dynamic!\n Or try to use static instead of anonymous/dynamic types.\nMore details about the error:\n - warning: (19, 5) The variable 'isbdd' is assigned but its value is never used\n\t - warning: (8, 4) Unnecessary using directive.\n\t - warning: (6, 4) Unnecessary using directive.\n\t - warning: (12, 4) Unnecessary using directive.\n\t - warning: (5, 4) Unnecessary using directive.\n\t - warning: (11, 4) Unnecessary using directive.\n\t - warning: (10, 4) Unnecessary using directive.\n\t - warning: (7, 4) Unnecessary using directive.\n\t - warning: (9, 4) Unnecessary using directive.\n\t - error: (0, 0) Unexpected error writing debug information -- 'Value cannot be null. (Parameter 'type')'\nTemporary files of the compilation can be found in (please delete the folder): /var/folders/25/7ht4yd49307crjldf5cmkbf80000gn/T/RazorEngine_pfpgylcf.1gz\nThe template we tried to compile is: \n------------- START -----------\n@using AventStack.ExtentReports\r\n@using AventStack.ExtentReports.ViewDefs\r\n@using RazorEngine\r\n@using RazorEngine.Templating\r\n@{\r\n\tvar isbdd = false;\r\n\tvar cls = \"\";\r\n\tif (Model.TestList.Count > 0 && Model.TestList[0].IsBehaviorDrivenType)\r\n\t{\r\n\t\tisbdd = true;\r\n\t\tcls = \"bdd-report\";\r\n\t}\r\n}\r\n<!DOCTYPE html>\r\n\r\n@Include(\"Head\")\r\n<script src=\"https://cdn.rawgit.com/extent-framework/extent-github-cdn/7cc78ce/spark/js/jsontree.js\">\r\n<
@shubautomation
OS: MAC TargetFramework: NET 6.0 IDE: vs2019(mac)
and what is specflow version? and Are you usin to specflow.nunit? or specflow.runner?
can i have .csproj package list information ?
Hi @namilkimfree
just note that in VS 2019 we don't have option to select any other version apart from .Netcore 3.1. Hence I selected .Netcoreapp 3.1 but later I changed the Target framework from project properties option) to .Net 6.0. But issue of Flush(); is in both .Netcore3.1 and 6.0 (Only On Mac)
I am using specflow.nunit.
.csproj >>
Project Sdk="Microsoft.NET.Sdk">
TargetFramework >netcoreapp3.1
sPackable>false>IsPackable
PropertyGroup
<PackageReference Include="NUnit" Version="3.13.3"
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1"
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2"
<PackageReference Include="SpecFlow" Version="3.9.74"
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.74"
<PackageReference Include="SpecFlow.NUnit" Version="3.9.74"
<PackageReference Include="Selenium.WebDriver" Version="4.5.1"
<PackageReference Include="ExtentReports" Version="4.1.0"
<PackageReference Include="Selenium.Support" Version="4.5.1"
<PackageReference Include="log4net" Version="2.0.15"
<PackageReference Include="SeleniumExtras.WaitHelpers" Version="1.0.2"
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57"
<PackageReference Include="ExtentReports.Core" Version="1.0.3"
@shubautomation
It seems to have been fixed in version 5.
Currently, only beta version exists.
I am using it separately through fork.
There seem to be two ways.
Use 5.0.0-alpha6.
Use ExtentReports-custom-package.
try change package ExtentReporter version 5.0.0-alpha6
`
`
and I don't think is needed. `
Hi @namilkimfree
Thanks for the response.
so this 2 ways are only applicable for MAC os ? as for windows it is working as expected.
Also, I know Version= "5.0.0-alpha6" can be downloaded from here: (https://www.nuget.org/packages/ExtentReports/5.0.0-alpha)
But can u tell me how to use "Use ExtentReports-custom-package."
Even if you use PackageReference Include="ExtentReports" Version="5.0.0-alpha6", it works normally on Windows, Linux, and mac.
CustomPackage: `
`
That package, and it's almost identical to the original functionality. If there are necessary functions or issues, they are added or used.
Hi @namilkimfree
Thanks for helping me. My some other questions. Sry to trouble again
In above comments Anshu mentioned to use .net standard with Extend Reporting 4.1.0, so I want to make sure I do not need to change anything from .Net related. Extent reporting 5.0-alpha version will resolve this issue? I am right here.?
Hi @shubautomation
If the following packages are included in the 5.x version, they exist in branch: develop.
If you check the above package
anshooarora
https://github.com/anshooarora/RazorEngine/tree/master/RazorEngine.NetCore/Compilation
Prevent debug errors on macOS
Fixed the issue.
Try changing the package version and test
Hi @shubautomation
If the following packages are included in the 5.x version, they exist in branch: develop.
If you check the above package
anshooarora
https://github.com/anshooarora/RazorEngine/tree/master/RazorEngine.NetCore/Compilation
Prevent debug errors on macOS
Fixed the issue.
Try changing the package version and test
Hi @namilkimfree
Did not get you here completely due to my limited knowledge on .Net.
Also, When I upgrade to ExtentReports" Version="5.0.0-alpha6, public static ExtentReports _extentReports; gives error "ExtentReports" is namespace but used as Type". And I am not able to find class ExtentReports anymore in 5.0.0-alpha6 version. Do we have any other equivalent class for Extentreports or any reference document for 5.0.0-alpha6 version. ?
Hi @shubautomation
It seems that NameSpace and Class name are the same.
using System.IO;
using AventStack.ExtentReports;
using TechTalk.SpecFlow;
using AventStack.ExtentReports.Reporter;
namespace MacLinuxTest
{
public class Hooks
{
private static ExtentReports _extentReports;
[BeforeTestRun]
public static void BeforeTestRun()
{
_extentReports = new ExtentReports();
var baseDirectory = Path.GetDirectoryName(typeof(Hooks).Assembly.Location);
var fileName = "nonWindows.html";
var path = Path.Combine(baseDirectory,fileName);
var extent = new ExtentReports();
var spark = new ExtentSparkReporter("Spark.html");
extent.AttachReporter(spark);
var sparkReport = new ExtentSparkReporter(path);
sparkReport.Config = new
AventStack.ExtentReports.Reporter.Config.ExtentSparkReporterConfig()
{
Theme = AventStack.ExtentReports.Reporter.Config.Theme.Dark
};
_extentReports.AttachReporter(sparkReport);
}
[AfterTestRun]
public static void AfterTestRun()
{
_extentReports.Flush();
}
}
}
Hi @shubautomation
using System.IO; using AventStack.ExtentReports; using TechTalk.SpecFlow; using AventStack.ExtentReports.Reporter; namespace MacLinuxTest { public class Hooks { private static ExtentReports _extentReports; [BeforeTestRun] public static void BeforeTestRun() { _extentReports = new ExtentReports(); var baseDirectory = Path.GetDirectoryName(typeof(Hooks).Assembly.Location); var fileName = "nonWindows.html"; var path = Path.Combine(baseDirectory,fileName); var extent = new ExtentReports(); var spark = new ExtentSparkReporter("Spark.html"); extent.AttachReporter(spark); var sparkReport = new ExtentSparkReporter(path); sparkReport.Config = new AventStack.ExtentReports.Reporter.Config.ExtentSparkReporterConfig() { Theme = AventStack.ExtentReports.Reporter.Config.Theme.Dark }; _extentReports.AttachReporter(sparkReport); } [AfterTestRun] public static void AfterTestRun() { _extentReports.Flush(); } } }
Hi @namilkimfree
Not sure what is wrong after Upgrade to 5.10-alpha version but not able to find the class ExtentReports. Please find the below screenshot
Hi @shubautomation
i use to verison
<PackageReference Include="ExtentReports" Version="5.0.0-alpha6" />
i'm not use 5.10-alpha
my .csproj
Hi @shubautomation
i use to verison
<PackageReference Include="ExtentReports" Version="5.0.0-alpha6" />
i'm not use 5.10-alpha
my .csproj
Hi @namilkimfree
Sorry that was typo error. My .csproj
PackageReference Include="ExtentReports" Version="5.0.0-alpha6" /> PackageReference Include="NUnit" Version="3.13.3" /> PackageReference Include="NUnit3TestAdapter" Version="4.2.1" /> PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> PackageReference Include="SpecFlow" Version="3.9.74" /> PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.74" /> PackageReference Include="SpecFlow.NUnit" Version="3.9.74" /> PackageReference Include="Selenium.WebDriver" Version="4.5.1" />
PackageReference Include="Selenium.Support" Version="4.5.1" />
PackageReference Include="log4net" Version="2.0.15" />
PackageReference Include="SeleniumExtras.WaitHelpers" Version="1.0.2" />
PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57" />
PackageReference Include="ExtentReports.Core" Version="1.0.3" />
but I am not able to find ExtentReports class anymore
Hi @shubautomation
you are also remove
It is caused by that package.
Delete that package.
Hi @shubautomation
you are also remove
It is caused by that package.
Delete that package.
Hi @namilkimfree
Are you taking abt package "PackageReference Include="ExtentReports.Core" Version="1.0.3"?? Sorry your comment was not clear.
Hi @shubautomation Sorry. missing my comment.
Yes, remove "PackageReference Include="ExtentReports.Core" Version="1.0.3
Hi @namilkimfree
First of all thanks a lot for helping me my initial issue for Razor template got fixed when I upgraded to 5.10-alpha and also I removed the package PackageReference Include="ExtentReports.Core" Version="1.0.3 which resolve my ExtentReports issue as well.
Can you please help me 2 more issues:
Can you suggest what is the method/function/class in Extent report 5.1.0-alpha6 use to take screenshots and attached to the extend reporting? Any document reference for 5.0.0-alpha6 version?
public static MediaEntityModelProvider CaptureScreenshot(string name) //{ // var screenshot = ((ITakesScreenshot)driver).GetScreenshot().AsBase64EncodedString; // return MediaEntityBuilder.CreateScreenCaptureFromBase64String(screenshot, name).Build(); //}
@namilkimfree @anshooarora Can you please help or else point to any reference link/document.
@shubautomation
- Earlier, I was capturing the screenshots for the failed Test cases and getting attached to the extent reporting by using below function. But once I removed the ExtentReports.Core package the class "MediaEntityModelProvider" is not available any more.
-->
public static Media CaptureScreenshot(string name)
{
var screenshot = ((ITakesScreenshot)driver).GetScreenshot().AsBase64EncodedString;
var media = MediaEntityBuilder.CreateScreenCaptureFromBase64String(base64, screenShotName).Build();
return media;
}
docs: https://www.extentreports.com/docs/versions/5/net/index.html
@shubautomation
- Earlier, I was capturing the screenshots for the failed Test cases and getting attached to the extent reporting by using below function. But once I removed the ExtentReports.Core package the class "MediaEntityModelProvider" is not available any more.
-->
public static Media CaptureScreenshot(string name) { var screenshot = ((ITakesScreenshot)driver).GetScreenshot().AsBase64EncodedString; var media = MediaEntityBuilder.CreateScreenCaptureFromBase64String(base64, screenShotName).Build(); return media; }
docs: https://www.extentreports.com/docs/versions/5/net/index.html
- can i have a your sample code?
@namilkimfree Sample code for hooks.cs from where I have listed all things related to Report
using TechTalk.SpecFlow; using AventStack.ExtentReports; using AventStack.ExtentReports.Reporter; using AventStack.ExtentReports.Gherkin.Model; using Demo_Test.Base; using TechTalk.SpecFlow.Infrastructure; using OpenQA.Selenium; //using NUnit.Engine.Extensibility; using NUnit.Framework.Interfaces; using System.Reflection; using OpenQA.Selenium.Remote; using System.IO; using System;
namespace Demo_Test.Support { [Binding]
public sealed class Hooks : BaseClass
{
// For additional details on SpecFlow hooks see http://go.specflow.org/doc-hooks
private static FileStream filestream;
public static StreamWriter sWriter;
[BeforeTestRun]
public static void BeforeTestRun()
{
string test = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName;
// Console.WriteLine("Report " + test);
var fileName = "nonWindows.html";
string reportPath = Path.Combine(test, "Report", fileName);
Console.WriteLine("Report full path : ", reportPath);
//_extentHtmlReporter = new ExtentHtmlReporter(test + @"\Report\");
//_extentHtmlReporter = new ExtentHtmlReporter(reportPath);
_extentSparkReporter = new ExtentSparkReporter(reportPath);
//old path not required //_extentHtmlReporter = new ExtentV3HtmlReporter(test + @"\Report\");
//_extentHtmlReporter.Config.ReportName = "System Test";
_extentSparkReporter.Config.ReportName = "System Test";
_extentReports = new ExtentReports();
//_extentReports.AttachReporter(_extentHtmlReporter);
_extentReports.AttachReporter(_extentSparkReporter);
_extentReports.AddSystemInfo("Host Name", "MAC");
_extentReports.AddSystemInfo("OS", "MAC");
}
[BeforeFeature]
public static void BeforeFeatureStart(FeatureContext featureContext)
{
if (featureContext != null)
{
_feature = _extentReports.CreateTest<Feature>(featureContext.FeatureInfo.Title,
featureContext.FeatureInfo.Description);
_feature.Info("This is test report of Info");
_feature.Log(Status.Info, "Starting the report");
}
}
[BeforeScenario]
public static void BeforeScenarioStart(ScenarioContext scenarioContext)
{
if (scenarioContext != null)
{
_scenarioContext = scenarioContext;
_scenario = _feature.CreateNode<Scenario>(scenarioContext.ScenarioInfo.Title,
scenarioContext.ScenarioInfo.Description);
}
driver = GetDriverInstance();
}
[AfterStep]
public void AfterEachStep()
{
ScenarioBlock scenarioBlock = _scenarioContext.CurrentScenarioBlock;
switch (scenarioBlock)
{
case ScenarioBlock.Given:
CreateNode<Given>();
break;
case ScenarioBlock.When:
CreateNode<When>();
break;
case ScenarioBlock.Then:
CreateNode<Then>();
break;
default:
CreateNode<And>();
break;
}
}
public void CreateNode<T>() where T : IGherkinFormatterModel
{
if (_scenarioContext.TestError != null)
{
var mediaEntity = CaptureScreenshot(_scenarioContext.ScenarioInfo.Title.Trim());
_scenario.CreateNode<T>(_scenarioContext.StepContext.StepInfo.Text).Fail(_scenarioContext.TestError.Message + "\n" +
_scenarioContext.TestError.StackTrace);
}
else
{
_scenario.CreateNode<T>(_scenarioContext.StepContext.StepInfo.Text).Pass("");
}
}
[AfterTestRun]
public static void AfterTestRun()
{
_extentReports.Flush();
//BaseClass.driver.Close();
}
[BeforeScenario("Firefox", Order = 1)]
public void FirstBeforeScenario()
{
// Example of ordering the execution of hooks
// See https://docs.specflow.org/projects/specflow/en/latest/Bindings/Hooks.html?highlight=order#hook-execution-order
//TODO: implement logic that has to run before executing each scenario
}
[AfterScenario]
public void AfterScenario()
{
sWriter.WriteLine("Test Finished: " + DateTime.Now);
if (_scenarioContext.TestError != null)
{
sWriter.WriteLine("Test Result: " + _scenarioContext.ScenarioInfo.Title + "_Fail");
}
else
{
sWriter.WriteLine("Test Result: " + _scenarioContext.ScenarioInfo.Title + "_Pass");
}
driver.Dispose();
driver = null;
sWriter.Close();
filestream.Close();
}
}
}
Hi @shubautomation
using System;
using System.IO;
using AventStack.ExtentReports;
using AventStack.ExtentReports.Gherkin.Model;
using TechTalk.SpecFlow;
using AventStack.ExtentReports.Reporter;
using AventStack.ExtentReports.Reporter.Config;
namespace MacLinuxTest
{
[Binding]
public sealed class Hooks
{
// For additional details on SpecFlow hooks see http://go.specflow.org/doc-hooks
private static ExtentSparkReporter _extentSparkReporter;
private static ExtentReports _extentReports;
private static ExtentTest _feature;
private static ScenarioContext _scenarioContext;
private static ExtentTest _scenario;
[BeforeTestRun]
public static void BeforeTestRun()
{
string test = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName;
// Console.WriteLine("Report " + test);
var fileName = "nonWindows.html";
string reportPath = Path.Combine(test, "Report", fileName);
Console.WriteLine("Report full path : ", reportPath);
//_extentHtmlReporter = new ExtentHtmlReporter(test + @"\Report\");
//_extentHtmlReporter = new ExtentHtmlReporter(reportPath);
_extentSparkReporter = new ExtentSparkReporter(reportPath);
//old path not required //_extentHtmlReporter = new ExtentV3HtmlReporter(test + @"\Report\");
//_extentHtmlReporter.Config.ReportName = "System Test";
_extentSparkReporter.Config.ReportName = "System Test";
_extentReports = new ExtentReports();
//_extentReports.AttachReporter(_extentHtmlReporter);
_extentReports.AttachReporter(_extentSparkReporter);
_extentReports.AddSystemInfo("Host Name", "MAC");
_extentReports.AddSystemInfo("OS", "MAC");
}
[BeforeFeature]
public static void BeforeFeatureStart(FeatureContext featureContext)
{
if (featureContext != null)
{
_feature = _extentReports.CreateTest<Feature>(featureContext.FeatureInfo.Title,
featureContext.FeatureInfo.Description);
_feature.Info("This is test report of Info");
_feature.Log(Status.Info, "Starting the report");
}
}
[BeforeScenario]
public static void BeforeScenarioStart(ScenarioContext scenarioContext)
{
if (scenarioContext != null)
{
_scenarioContext = scenarioContext;
_scenario = _feature.CreateNode<Scenario>(scenarioContext.ScenarioInfo.Title,
scenarioContext.ScenarioInfo.Description);
}
//driver = GetDriverInstance();
}
[AfterStep]
public void AfterEachStep()
{
ScenarioBlock scenarioBlock = _scenarioContext.CurrentScenarioBlock;
switch (scenarioBlock)
{
case ScenarioBlock.Given:
CreateNode<Given>();
break;
case ScenarioBlock.When:
CreateNode<When>();
break;
case ScenarioBlock.Then:
CreateNode<Then>();
break;
default:
CreateNode<And>();
break;
}
}
public void CreateNode<T>() where T : IGherkinFormatterModel
{
if (_scenarioContext.TestError != null)
{
//var mediaEntity = null;
_scenario.CreateNode<T>(_scenarioContext.StepContext.StepInfo.Text).Fail(_scenarioContext.TestError.Message + "\n" +
_scenarioContext.TestError.StackTrace);
}
else
{
_scenario.CreateNode<T>(_scenarioContext.StepContext.StepInfo.Text).Pass("");
}
}
[AfterTestRun]
public static void AfterTestRun()
{
_extentReports.Flush();
//BaseClass.driver.Close();
}
[AfterScenario]
public void AfterScenario()
{
if (_scenarioContext.TestError != null)
{
}
else
{
}
//driver.Dispose();
//driver = null;
}
}
}
All Pass
One Pass, One Fail
using System; using System.IO; using AventStack.ExtentReports; using AventStack.ExtentReports.Gherkin.Model; using TechTalk.SpecFlow; using AventStack.ExtentReports.Reporter; using AventStack.ExtentReports.Reporter.Config;
namespace MacLinuxTest { [Binding] public sealed class Hooks { // For additional details on SpecFlow hooks see http://go.specflow.org/doc-hooks
private static ExtentSparkReporter _extentSparkReporter; private static ExtentReports _extentReports; private static ExtentTest _feature; private static ScenarioContext _scenarioContext; private static ExtentTest _scenario; [BeforeTestRun] public static void BeforeTestRun() { string test = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName; // Console.WriteLine("Report " + test); var fileName = "nonWindows.html"; string reportPath = Path.Combine(test, "Report", fileName); Console.WriteLine("Report full path : ", reportPath); //_extentHtmlReporter = new ExtentHtmlReporter(test + @"\Report\"); //_extentHtmlReporter = new ExtentHtmlReporter(reportPath); _extentSparkReporter = new ExtentSparkReporter(reportPath); //old path not required //_extentHtmlReporter = new ExtentV3HtmlReporter(test + @"\Report\"); //_extentHtmlReporter.Config.ReportName = "System Test"; _extentSparkReporter.Config.ReportName = "System Test"; _extentReports = new ExtentReports(); //_extentReports.AttachReporter(_extentHtmlReporter); _extentReports.AttachReporter(_extentSparkReporter); _extentReports.AddSystemInfo("Host Name", "MAC"); _extentReports.AddSystemInfo("OS", "MAC"); } [BeforeFeature] public static void BeforeFeatureStart(FeatureContext featureContext) { if (featureContext != null) { _feature = _extentReports.CreateTest<Feature>(featureContext.FeatureInfo.Title, featureContext.FeatureInfo.Description); _feature.Info("This is test report of Info"); _feature.Log(Status.Info, "Starting the report"); } } [BeforeScenario] public static void BeforeScenarioStart(ScenarioContext scenarioContext) { if (scenarioContext != null) { _scenarioContext = scenarioContext; _scenario = _feature.CreateNode<Scenario>(scenarioContext.ScenarioInfo.Title, scenarioContext.ScenarioInfo.Description); } //driver = GetDriverInstance(); } [AfterStep] public void AfterEachStep() { ScenarioBlock scenarioBlock = _scenarioContext.CurrentScenarioBlock; switch (scenarioBlock) { case ScenarioBlock.Given: CreateNode<Given>(); break; case ScenarioBlock.When: CreateNode<When>(); break; case ScenarioBlock.Then: CreateNode<Then>(); break; default: CreateNode<And>(); break; } } public void CreateNode<T>() where T : IGherkinFormatterModel { if (_scenarioContext.TestError != null) { //var mediaEntity = null; _scenario.CreateNode<T>(_scenarioContext.StepContext.StepInfo.Text).Fail(_scenarioContext.TestError.Message + "\n" + _scenarioContext.TestError.StackTrace); } else { _scenario.CreateNode<T>(_scenarioContext.StepContext.StepInfo.Text).Pass(""); } } [AfterTestRun] public static void AfterTestRun() { _extentReports.Flush(); //BaseClass.driver.Close(); } [AfterScenario] public void AfterScenario() { if (_scenarioContext.TestError != null) { } else { } //driver.Dispose(); //driver = null; } }
}
Hi @namilkimfree
Thanks for sharing the report. I don't think there is any difference in your hooks.cs file and mine. But still I am not able to get all the ran Tcs. Only latest ran Tcs is getting reported in the report.
Can you suggest which file can cause prob will share the code for the same with you. There might be some config changes in 5 Version of extent report as it might be overriding my previous Tcs ran result. Please help on the same
After Analysis: I found that for every scenario it is executing [BeforeTestRun] block which should be ideally executed only once for 1 run and same for [AfterTestRun] which is getting executed for every scenario. These both blocks cover code to generate the report hence it is getting executed again for every scenario the previous results and getting overridden . In My windows OS, [AfterTestRun] and [BeforeTestRun] blocks are excuting only once per run not with every scenarios. Can you please help how to fix this and this wont look like reporting issue, moreover it is related to nUnit + Specflow issue. Please suggest.
Hi @shubautomation [AfterTestRun] and [BeforeTestRun]
It is called only once. Even if there are 3 scenarios
are you using parallelExecution?
Hi @shubautomation [AfterTestRun] and [BeforeTestRun]
It is called only once. Even if there are 3 scenarios
are you using parallelExecution?
Hi @namilkimfree
I am not using Parallel Execution and when I am running the 2 scenarios it is executing in sequence and not in parallel. As I said in my previous comment that when I did analysis I found that [AfterTestRun] and [BeforeTestRun] is executing for every scenario run and not once for complete run. Hence my report is overriding the previous result.
Any pointers how to fix this?. It is very strange why it is happening like this. Anything to do with nUnit.assembly.hooks.cs?
Hello @shubautomation
Can you upload your code to your github repository?
Hi @namilkimfree
I have created the sample project and zip file is attached with this comment. Please use this project. Issue is reproducible as only latest ran TC is reported in the report because [BeforeTestRun] and [AfterTestRun] is getting executed with every scenarios. Also [OnetimeSetup] and [OneTimeTearDown] block in nUnit.AssemblyHooks.cs is also getting executed with every scenarios, ideally this also should be run only once per execution.
Let me know if you any issue while downloading or using my sample project.
Note: I am using Mac OS + Specflow + nUnit + VS 2019 + DotNet coreapp 3.1. Also I have installed specflow integration package with Mac OS. https://github.com/straighteight/SpecFlow-VS-Mac-Integration as Specflow is not officially released for MAC OS.
Are you also using MAC OS +Specflow+nUnit + VS 2019?
Do you mind sharing your email? We can continue our discussion over email. Do not want spam the other users.
Hi @namilkimfree
Did you get chance to look into the sample project? I am not able to find the solution yet.
Hi @shubautomation
sorry
i don't have Mac OS
Reporting the results of two scenarios is success on Windows OS.
I have a Mac at work, but it's taking a long time to set up an old Mac mini.
wait please
Hi @shubautomation
sorry
i don't have Mac OS
Reporting the results of two scenarios is success on Windows OS.
I have a Mac at work, but it's taking a long time to set up an old Mac mini.
wait please
Hi @namilkimfree
Thanks a lot for the reply.
Yes. in Windows OS everything is working as expected for me as well. Sure will wait for your update.
Hi @namilkimfree,
Did u get the change to reproduce the issue in MAC?
@shubautomation hi
When running with the project, a report with two scenarios passed without any problems is created.
My mac: vs2022, dotnet6
Hi,
I am facing a weird issue, so far the extent report was working fine, but all of a sudden it has stopped working, and started throwing RazorEngine excetption. the exception is shown below: