question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unit Tests randomly fail

See original GitHub issue

Hi,

I am some issue with this module. It seems that when calling app.UseFastEndpoints();

Tests are randomly failing with Error: The server has not been started or no web application was configured.

Culprit: Task.Run(async () => It seems that after 1 minute this static variables (discoveredEndpointDefinitions) gets set to null

I know that I am using Specflow/xUnit and that a the WebApplicaitonFactory is created for every scenario; I tried disabling the parallelism, but tests run too slow.

Why is the code doing that ? And could we make it configurable or be able to disable that behavior ?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
bobbyangerscommented, Dec 15, 2021

Ok I’ll try v2.11; Yes this is throw by the TestHost which is used by WAF
When calling CreateClient (on the WAF) it’s like the application never got created… or did not have time to finish creating.

This article from Andrew Lock : Supporting integration tests with WebApplicationFactory in .NET 6 explain in quite a bit of details that might be of interest.

0reactions
dj-nitehawkcommented, Dec 15, 2021

could you pls give v2.11 a try with your setup. it might solve you problem if contetion was the actual cause. if not, you may still wanna look into temporarily disabling old TestHosts and running just WAF.

Read more comments on GitHub >

github_iconTop Results From Across the Web

jenkins - Unit tests sometimes failing, sometimes passing
Tests can fail intermittently for a number of reasons and identifying why they fail is often revealing about your codebase and environment.
Read more >
How to Fix Flaky Tests - Semaphore CI
A test that intermittently fails for no apparent reason — or works in your local machine and fails with continuous integration — is...
Read more >
Tests that sometimes fail
Unit tests also sometimes fail because of not cleaning up state properly, which only breaks things when tests run in a very specific...
Read more >
Why The Tests Are Randomly Failing
There are three general reasons that “random” is causing tests to fail: (i) the randomly generated data is showing real errors in the...
Read more >
Diagnosing Random Angular Test Failures
Understand that tests run in no particular order, and that is ideally what you want. Turn off random execution to help find the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found