anshooarora / extentreports-csharp

Community version of Extent API for .NET has moved to https://github.com/extent-framework/
http://extentreports.com/
Other
47 stars 43 forks source link

System.InvalidOperationException : Collection was modified; enumeration operation may not execute. #103

Closed BottlecapDave closed 6 years ago

BottlecapDave commented 6 years ago

Not sure if to create a new issue or attach a comment to https://github.com/anshooarora/extentreports-csharp/issues/75. When using ExtentReports with xunit and tests executed in parallel, I'm sometimes receiving the following stack trace and exception:

Result StackTrace:
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) at System.Collections.Generic.List1.ForEach(Action1 action) at AventStack.ExtentReports.Model.Test.UpdateTestStatusRecursive(Test test) at AventStack.ExtentReports.Model.Test.End() at AventStack.ExtentReports.Model.Test.<>c.b__73_0(Test x) at System.Collections.Generic.List1.ForEach(Action1 action) at AventStack.ExtentReports.Model.Test.EndChildTestsRecursive(Test test) at AventStack.ExtentReports.Model.Test.End() at AventStack.ExtentReports.Model.Report.EndTest(Test test) at AventStack.ExtentReports.Model.Report.b__19_0(Test test) at System.Collections.Generic.List1.ForEach(Action1 action) at AventStack.ExtentReports.Model.Report.CollectRunInfo() at AventStack.ExtentReports.Model.Report.AddLog(Test test, Log log) at AventStack.ExtentReports.ExtentTest.AddLog(Log evt) at AventStack.ExtentReports.ExtentTest.Log(Status status, String details, MediaEntityModelProvider provider) at AventStack.ExtentReports.ExtentTest.Pass(String details, MediaEntityModelProvider provider)

I'm not sure if this is any help, but I'm using ExtentReports with a gherkin structure as I'm using it with Specflow and xUnit. The creation of the step node and the passing/failing of said node is done within the AfterStep callback.

anshooarora commented 6 years ago

Version?

BottlecapDave commented 6 years ago

I am currently using 3.0.2. I see that there is a newer version out, so will try that

anshooarora commented 6 years ago

Yes, version 3.1 launched yesterday. Please check.

anshooarora commented 6 years ago

Are you able to reproduce this? If not, can this be closed?

anshooarora commented 6 years ago

Closing this for now. Please reopen or create a new issue if you encounter this again.

andrewlaser commented 6 years ago

Currently the latest C# ExtentReports 3.1.3 with NUnit 3.10.1 Got the same random issue when running tests in parallel. 14:29:27,523 Thread#ParallelWorker#4 - ERROR: Exception message: Collection was modified; enumeration operation may not execute.

StackTrace:    at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at AventStack.ExtentReports.SessionStatusStats.ExtractStandardTestCountsTestStrategy(Test test)
   at AventStack.ExtentReports.SessionStatusStats.<ExtractStandardTestCountsTestStrategy>b__108_1(Test x)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at AventStack.ExtentReports.SessionStatusStats.ExtractStandardTestCountsTestStrategy(Test test)
   at AventStack.ExtentReports.SessionStatusStats.ExtractCounts(Test test)
   at AventStack.ExtentReports.SessionStatusStats.<UpdateCounts>b__102_0(Test x)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at AventStack.ExtentReports.SessionStatusStats.UpdateCounts()
   at AventStack.ExtentReports.SessionStatusStats.Refresh(List`1 testCollection)
   at AventStack.ExtentReports.Model.Report.CollectRunInfo()
   at AventStack.ExtentReports.Model.Report.AddLog(Test test, Log log)
   at AventStack.ExtentReports.ExtentTest.AddLog(Log evt)
   at AventStack.ExtentReports.ExtentTest.Log(Status status, String details, MediaEntityModelProvider provider)
   at AventStack.ExtentReports.ExtentTest.Debug(String details, MediaEntityModelProvider provider)
   at RS.Framework.Pages.Page.FluentlyWaitForElementToBePresent(By element, Int32 timeoutSeconds) in C:\BuildAgent\work\c9058bdd19501473\RS.Framework\Pages\Page.cs:line 303
   at RS.Framework.Pages.Admin.AdminHeader..ctor(RsWebDriver rsWebDriver) in C:\BuildAgent\work\c9058bdd19501473\RS.Framework\Pages\Admin\AdminHeader.cs:line 53
   at RS.Framework.Pages.Admin.Test.ToBeProcessedPage..ctor(RsWebDriver rsWebDriver) in C:\BuildAgent\work\c9058bdd19501473\RS.Framework\Pages\Admin\Test\ToBeProcessedPage.cs:line 20
   at RS.Tests.Tests.CSC_CustomerService_Collections.Ops.NoSiACommunicationCases.NoSiATemplateLetter() in C:\BuildAgent\work\c9058bdd19501473\RS.Tests\Tests\CSC_CustomerService_Collections\Ops\NoSiACommunicationCases.cs:line 167 

Please, provide at least some temporary workaround. I'm developing a proof of concept for my current project. Won't be able to persuade my management to buy a license for something that doesn't work :(

MattKeenum commented 5 years ago

I am running v3.1.3 and I ran into this issue when running in parallel. I am attempting to use locks to prevent this from happening, but I would prefer not too.

Result Message: System.InvalidOperationException : Collection was modified; enumeration operation may not execute.

Result StackTrace:  
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at AventStack.ExtentReports.Model.Test.UpdateTestStatusRecursive(Test test)
   at AventStack.ExtentReports.Model.Test.End()
   at AventStack.ExtentReports.Model.Report.EndTest(Test test)
   at AventStack.ExtentReports.Model.Report.<CollectRunInfo>b__19_0(Test test)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at AventStack.ExtentReports.Model.Report.CollectRunInfo()
   at AventStack.ExtentReports.Model.Report.AddLog(Test test, Log log)
   at AventStack.ExtentReports.ExtentTest.AddLog(Log evt)
   at AventStack.ExtentReports.ExtentTest.Log(Status status, String details, MediaEntityModelProvider provider)
   at AventStack.ExtentReports.ExtentTest.Pass(String details, MediaEntityModelProvider provider)