Closed mhgames closed 7 years ago
I'm currently using locks to get rid of this message, but apparently the more tests I have, the slower the run is, since the ForEach takes longer and longer.
Can you please try with the attached dll. Any luck?
I removed all the locks and it works, no error. Also the profiler no longer says that ExtentReports are causing performance issues. Thanks!
I've never had issues with Java implementation of ExtentReports (version 2.4) running Selenium tests in parallel in the past.
But currently I'm running some API tests on C# implementation of ExtentReports in parallel and these tests are very fast, so when I'm calling .Log(...) on ExtentTest, I end up (from time to time) with System.InvalidOperationException (Collection was modified; enumeration operation may not execute.)
Here's part of the stacktrace: at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) at System.Collections.Generic.Listb__73_0(Test x)
at System.Collections.Generic.Listb__19_0(Test test)
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.Test.<>c.1.ForEach(Action
1 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.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)Since it's an error on System.Collections.Generic.List, it could imho be solved in your AbstractStructure.cs file with ConcurrentDictionary instead of List _list, with integer TKey as array index and TValue as array value, since there's no ConcurrentList in C# yet and ConcurrentBag is unordered.