New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
BottlecapDave opened this Issue Feb 15, 2018 · 7 comments

Comments

Projects
None yet
4 participants
@BottlecapDave

BottlecapDave commented Feb 15, 2018

Not sure if to create a new issue or attach a comment to #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 anshooarora added the bug label Feb 17, 2018

@anshooarora

This comment has been minimized.

Owner

anshooarora commented Feb 17, 2018

Version?

@BottlecapDave

This comment has been minimized.

BottlecapDave commented Feb 21, 2018

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

@anshooarora

This comment has been minimized.

Owner

anshooarora commented Feb 21, 2018

Yes, version 3.1 launched yesterday. Please check.

@anshooarora

This comment has been minimized.

Owner

anshooarora commented Feb 27, 2018

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

@anshooarora

This comment has been minimized.

Owner

anshooarora commented Mar 1, 2018

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

@anshooarora anshooarora closed this Mar 1, 2018

@andrewlaser

This comment has been minimized.

andrewlaser commented Sep 12, 2018

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

This comment has been minimized.

MattKeenum commented Nov 23, 2018

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment