Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

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

Closed
BottlecapDave opened this issue Feb 15, 2018 · 7 comments
Labels

Comments

@BottlecapDave
Copy link

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
Copy link
Owner

Version?

@BottlecapDave
Copy link
Author

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

@anshooarora
Copy link
Owner

Yes, version 3.1 launched yesterday. Please check.

@anshooarora
Copy link
Owner

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

@anshooarora
Copy link
Owner

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

@andrewlaser
Copy link

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
Copy link

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants