zzzprojects / EntityFramework-Effort

Entity Framework Effort is a powerful tool that enables a convenient way to create automated tests for Entity Framework based applications.
https://entityframework-effort.net/
MIT License
431 stars 99 forks source link

Test runs forever without a ToList() on repository query #218

Closed C-Wal closed 7 months ago

C-Wal commented 7 months ago

I am facing an odd issue with Effort.EF6 on an old .Net Framework solution. The setup is as follows:

A .Net Framework 4.7.2 test project in C#, testing code in a .Net Framework 4.6.2 class library project in VB.Net.

The code under test does a query against a repository, iterates the result and performs work, then saves all changes once done.

My test data has a single record.

What happens is that when I run the test in isolation it passes, when I run it as part of a dozen tests it passes, but when I run it as part of the full suite of a couple of hundred tests it runs forever, doesn't complete, and I have to eventually kill the test runner after a few hours.

The really odd thing is that if I add a .ToList() on the end of my repository query then the test always works fine, even when run as part of the full suite, but that means I have to change my already working code to let the test pass.

I could take the time to try and create a repo but as I have a workaround it's not going to be worth the effort, but I wondered if you knew of this issue or what the cause might be?

JonathanMagnan commented 7 months ago

Hello @C-Wal ,

Are you running your test through multi-threading? If yes, perhaps the solution found by RuneAndersen could help you. See his solution: https://github.com/zzzprojects/EntityFramework-Effort/issues/152#issuecomment-1941228564

Best Regards,

Jon

C-Wal commented 7 months ago

Hi Jon. I'm not and I'm using CreateTransient anyway.

JonathanMagnan commented 7 months ago

Hello @C-Wal ,

In this case, we are not sure about this issue.

If you ever get the time to provide a project, let us know and we will look more deeply about this current issue.

Best Regards,

Jon