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 Collection Cleanup Failure #49615
Comments
These exceptions seem to be coming from within IdentityServer thinking the server hasn't been started. Is the constructor working OK and the server is starting correctly? Is IdentityServer configured appropriately? I wonder if the sometimes-it-works/sometimes-it-doesn't-work is related to the background tasks in those hosted services. Something you could try refactoring to see if it changes anything is to setup and tear down the fixture using [Collection("Tests Collection")]
public class AuthorizeEndpointIntegrationTests : IAsyncLifetime
{
private readonly CustomWebApplicationFactory<Program> _factory;
public AuthorizeEndpointIntegrationTests(CustomWebApplicationFactory<Program> factory) => _factory = factory;
public Task InitializeAsync()
{
using (_factory.CreateDefaultClient())
{
// Force the server to start
}
return Task.CompletedTask;
}
public async Task DisposeAsync()
{
await using (var scope = _factory.Services.CreateAsyncScope())
{
var scopedServices = scope.ServiceProvider;
var myDb = scopedServices.GetRequiredService<MyDbContext>();
SeedData.CleanUpTestData(myDb);
}
}
} If you're still having issues, a self-contained reproducible example of the issue would help. |
Hi @khteh. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Please provide more info / reference for |
Is |
Calling any of the methods that create an
Which bit do you think is a mistake? It's the same syntax as your code, except I'm assigning the fixture into a field instead of the result of calling |
Hi @khteh. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Isn't it done in my code? Please check the original post:
There is no assignment in your constructor. You just referenced the field. I expected |
Here's the code from your original post. I just amended it. It's using a C# expression-bodied constructor to set the value of the If you're not familiar with this syntax, it's the same as: public class AuthorizeEndpointIntegrationTests : IAsyncLifetime
{
private readonly CustomWebApplicationFactory<Program> _factory;
public AuthorizeEndpointIntegrationTests(CustomWebApplicationFactory<Program> factory)
{
factory = _factory;
}
} Having written the above, I can now see it was just a minor typo in the GitHub written (not IDE written, so no compiler error checking) code example. |
Hi @khteh. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
I don't get the point of your answers / posts here. My original post already calls |
I'm suggesting moving it out of the constructor and keeping the fixture in the class, so that if it fails it's easier to separate out as it would happen in a dedicated method. The rationale being that sometimes constructors throw, and then the class is disposed, but a bug in the dispose code called via a finalizer might assume the constructor never fails, and then throw. Refactoring the fixture as I suggested would help with determining whether that is the case. Whether you think that suggestion has merit or not, the exceptions appear to be coming from IdentityServer code, so if there's an issue in ASP.NET Core a fully-reproducible example is likely going to be needed to show that that is indeed the case. |
Hi @khteh. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Thank you for filing this issue. In order for us to investigate this issue, please provide a minimalistic repro project that illustrates the problem. |
What's the diff betwee
but to no avail. |
They're just different overloads, but I suggested using that one because it's the default 😄 aspnetcore/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs Lines 454 to 473 in 1bda10b
So it doesn't fix it, but are the exceptions being thrown the same? If it's still not working, please provide a self-contained repro including the IdentityServer parts where the exceptions are coming from. |
Hi @khteh. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
|
|
Hi @khteh. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
When is the
I only want to clean up and dispose after all the tests in the "Test Collection" completes. |
Using
I understand what you're trying to do, but the call to |
Hi @khteh. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate. See our Issue Management Policies for more information. |
Is there an existing issue for this?
Describe the bug
Sometime it passes, sometime it fails.
Expected Behavior
No exception
Steps To Reproduce
No response
Exceptions (if any)
.NET Version
7.0.304
Anything else?
.NET SDK:
Version: 7.0.304
Commit: 7e794e2806
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.304\
Host:
Version: 7.0.7
Architecture: x64
Commit: 5b20af47d9
.NET SDKs installed:
6.0.202 [C:\Program Files\dotnet\sdk]
6.0.401 [C:\Program Files\dotnet\sdk]
7.0.100 [C:\Program Files\dotnet\sdk]
7.0.304 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
The text was updated successfully, but these errors were encountered: