VahidN / EFSecondLevelCache.Core

Entity Framework Core Second Level Caching Library
Apache License 2.0
326 stars 51 forks source link

Use XUnit instead of MSTest for the test project. #62

Closed codertimu closed 4 years ago

codertimu commented 4 years ago

Some tests are failing. Can it be because XUnit runs tests in parallel?

VahidN commented 4 years ago

Thank you. I'm not going to use XUnit here, so I won't merge it. But you shouldn't remove the TestInitialize part. It's necessary to flush the entire cache system before each test (starting from zero and completely independent from the other parts). If XUnit doesn't have it, you should call the _serviceProvider.GetRequiredService<IEFCacheServiceProvider>().ClearAllCachedEntries(); at the beginning of each test method.

codertimu commented 4 years ago

Hi Vahid,

I opened the PR to review the issue and not to merge actually. The XUnit counterpart of TestInitialize is the constructor of the test class. (Dispose method for TestCleanup, of course by implementing IDisposable). You can have a look at how xunit, nunit and mstest handles the same things differently: https://xunit.net/docs/comparisons

So, theoretically this PR is equivalent to original tests. But some tests are failing and it is hard to find the reason because when they run alone they are passing. When all tests run, some tests are failing. Can this be because XUnit runs tests in parallel?If that is the case, what should we do cause clearing the cache in test does not help.