-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test outcome different when running normal vs. running with debugger attached #1924
Comments
Would you be able to create a reproduction repo? Without knowing what the factory and services you're using are I can't really replicate it |
Not sure how I could do this without basically sharing our whole project. It's an integration test so each and every service is loaded into it. Trying to strip the service but keep the setup of services is quite tedious and in my experience often so invasive that potential bugs appear or disappear by these changes. I hoped the odd scenario and the stacktrace might already help giving a clue as to what could be wrong. Is there anything I can do to get more info? I mean it's odd that something should be disposed mid-test. The logs are not that easy to read but there are some oddities to be found. To me it seems like there's something wrong with the injection maybe? The test class inherits: public abstract class TestBase
{
[ClassDataSource<ServiceFactory>(Shared = SharedType.PerTestSession)]
public required ServiceFactory Factory { get; set; }
} and the factory itself looks like this: public sealed class ServiceFactory : WebApplicationFactory<Program>, IAsyncInitializer
{
public Task InitializeAsync()
{
// You can also override certain services here to mock things out
// Grab a reference to the server
// This forces it to initialize.
// By doing it within this method, it's thread safe.
// And avoids multiple initialisations from different tests if parallelisation is switched on
_ = Server;
return Task.CompletedTask;
}
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
builder.ConfigureTestServices(services =>
{
services.AddTransient<ITestUserProvider, TestUserProvider>();
services.AddAuthentication("TestScheme").AddScheme<AuthenticationSchemeOptions, TestingAuthenticationHandler>("TestScheme", options => { });
});
base.ConfigureWebHost(builder);
}
} |
I have a similar setup with a base class except my property-injected WebApplicationFactory is I started having the same exception after upgrading TUnit from |
Well I can at least tell that switching to XUnit fixed it. I can try to reproduce it with a small repository the coming days when I find time. I guess it shouldn't be that hard to reproduce. Seems like this can occur even with a basic setup. |
I'll try and reproduce it - And if anyone beats me to it, please share as it'll be very useful 😄 |
Could you try v0.14.13 please and let me know if it still occurs |
Still happening with v0.14.13 |
@Dalet if you can get me a reproduction at any point that'll help as I can't recreate it |
Well, I have the following (integration) test which has multiple arguments specified for different cases:
When I run it normally it fails with this exception:
When I debug this test case it does not fire this exception but instead run through to the assertions and fail due to an expected issue (test setup not yet done correctly).
The weird thing is: When I run any other test case on this test I get success back. Only the one that should actually succeed fails with this exception. It fails the assertion if debugged through.
What could be the issue? I don't understand why one scenario would cause a disposed exception while others work fine. And why does it not fail when I debug through?
Seems like there is a bug in TUnit. Could be some kind of race condition?
The text was updated successfully, but these errors were encountered: