Exception thrown randomly when testing.
See original GitHub issueIm using xUnit and WebApplicationFactory to create a test server. I wrote some test. When I run all one or two randomly fails. Run again and they succeed.
Here is my exception:
Message:
System.InvalidOperationException : Collection was modified; enumeration operation may not execute.
Stack Trace:
Enumerator.MoveNextRare()
Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
EndpointDefinition.<PostProcessors>b__139_0(IGlobalPostProcessor p)
WhereArrayIterator`1.MoveNext()
List`1.InsertRange(Int32 index, IEnumerable`1 collection)
EndpointDefinition.PostProcessors(IGlobalPostProcessor[] postProcessors)
<>c__DisplayClass0_0.<<Main>$>b__7(EndpointDefinition ep) line 58
MainExtensions.MapFastEndpoints(IEndpointRouteBuilder app, Action`1 configAction)
MainExtensions.UseFastEndpoints(WebApplication app, Action`1 configAction)
Program.<Main>$(String[] args) line 51
Program.<Main>(String[] args)
InvokeStub_Program.<Main>(Object, Object, IntPtr*)
MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
--- End of stack trace from previous location ---
DeferredHost.StartAsync(CancellationToken cancellationToken)
HostingAbstractionsHostBuilderExtensions.StartAsync(IHostBuilder hostBuilder, CancellationToken cancellationToken)
HostingAbstractionsHostBuilderExtensions.Start(IHostBuilder hostBuilder)
TraffiCaptureFactoryBase.CreateHost(IHostBuilder builder) line 47
WebApplicationFactory`1.ConfigureHostBuilder(IHostBuilder hostBuilder)
WebApplicationFactory`1.EnsureServer()
WebApplicationFactory`1.get_Services()
Any idea whats going wrong?
Issue Analytics
- State:
- Created a year ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
How do I simulate throwing an exception at random point of ...
1- Make a function called RandomException(); that throw exception if a random value is divisible by 3 otherwise it won't throw the exception....
Read more >Assert an Exception Is Thrown in JUnit 4 and 5
In this quick tutorial, we'll be looking at how to test if an exception was thrown using the JUnit library.
Read more >Testing Exceptions: Harder Than It Looks
Exceptions are one of the most complicated constructs in many languages. We'll look at several ways to test them.
Read more >Why are JUnit tests throwing errors randomly (Java ...
There could be several reasons why JUnit tests are throwing errors randomly. Some possibilities include: **Inconsiste. Continue reading.
Read more >ITestOutputHelper throws exception "There is no currently ...
Hi guys,. I can't figure out this problem.... I have a .NET Framework 4.7.2 xUnit Project to test our DataModel Objects: it counts...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@szekelymatyas that was actually helpful to find the culprit. thank you very much! fixed in
v5.2.0-beta10
Im using visual studio with xunit right know. But the problem has occured in rider too, if i remember correctly. Later im gonna pull de source, but right know i have a lot of think to do. The biggest problem is that its only happens 2-3 times in about 100. So im not sure how to reproduce it deterministicly.