-
Notifications
You must be signed in to change notification settings - Fork 572
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
9.1 Test Templates don't use new 9.1 Test Features #7606
Comments
Ideally for this, we would plug in to the test framework's cancellation mechanisms: MSTest: [TestClass]
public class IntegrationTest1(TestContext context)
{
[TestMethod]
[Timeout(30_000)]
public async Task GetWebResourceRootReturnsOkStatusCode()
{
var cancellationToken = context.CancellationTokenSource.Token; NUnit [Test]
[CancelAfter(30_000)]
public async Task GetWebResourceRootReturnsOkStatusCode(CancellationToken cancellationToken)
{ XUnit (Does require upgrading from [Fact(Timeout=30_000)]
public async Task GetWebResourceRootReturnsOkStatusCode()
{
var cancellationToken = TestContext.Current.CancellationToken; (If upgrading to xunit.v3, also consider setting |
Thanks for this @afscrome!
Agreed.
I agree this would be helpful as it sets up the test for much easier failure analysis. It might be easier to just enable all "Aspire" logs though (that's what we do in the samples repo tests). Is there concern that would be too noisy? We should likely add
Agreed, but for the
Yes. I'll put a PR up with these changes and we can continue any further conversation there. |
Oh and RE updating to xUnit.net v3, we're tracking that separately in #7225 |
* Improve testing templates Fixes #7606 * Add missing namespace & fix variable name
* Improve testing templates Fixes #7606 * Add missing namespace & fix variable name --------- Co-authored-by: Damian Edwards <[email protected]>
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
A lot of new testing goodness has been added in Aspire 9.1, but the test templates have hardly changed so don't expose much of this.
(This issue assumes that https://github.com/dotnet/aspire/tree/main/src/Aspire.ProjectTemplates/templates/aspire-starter/9.1/Aspire-StarterApplication.1.Tests is the intended template due to #7603)
Describe the solution you'd like
app.Services.GetRequiredService<ResourceNotificationService>()
should be replaced withapp.ResourceNotifications
In order to get details about health check failures and resources not ending up in the expected state, we should consider adding the following to app host configuration in the default test. Users can opt out of these if they don't need them, but by having them in the default template, it's a strong indicator to users that these logs may be useful.
Cancellation/Timeouts should be added to the
app.StartAsync()
call, as this could hang indefinitely in certain chains ofWaitFor
dependencies, so that users can see the health check & resource notification logs to see why their test hung. (For completeness, cancellation also ought to be added to theappHost.BuildAsync
andhttpClientGetAsync()
)Should
WaitForResourceAsync
be replaced withWaitForResourceHealthyAsync
Additional context
No response
The text was updated successfully, but these errors were encountered: