-
Notifications
You must be signed in to change notification settings - Fork 659
Caitie/update test templates #10662
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
base: main
Are you sure you want to change the base?
Caitie/update test templates #10662
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the Aspire test project templates to follow proper resource disposal best practices by adding using
declarations for disposable resources and improving cancellation token usage across multiple test framework templates.
- Updates resource disposal patterns for HttpClient, HttpResponse, and CancellationTokenSource
- Standardizes cancellation token usage to leverage framework-provided tokens in MSTest templates
- Applies consistent best practices across XUnit, NUnit, and MSTest project templates for versions 9.3 and 9.4
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/Aspire.ProjectTemplates/templates/aspire-xunit/9.4/IntegrationTest1.cs | Added using declarations for CancellationTokenSource, HttpClient, and HttpResponse |
src/Aspire.ProjectTemplates/templates/aspire-xunit/9.3/IntegrationTest1.cs | Added using declarations for CancellationTokenSource, HttpClient, and HttpResponse |
src/Aspire.ProjectTemplates/templates/aspire-nunit/9.4/IntegrationTest1.cs | Added using declarations for CancellationTokenSource, HttpClient, and HttpResponse |
src/Aspire.ProjectTemplates/templates/aspire-nunit/9.3/IntegrationTest1.cs | Added using declarations for CancellationTokenSource, HttpClient, and HttpResponse |
src/Aspire.ProjectTemplates/templates/aspire-mstest/9.4/IntegrationTest1.cs | Added TestContext property and updated to use framework cancellation token plus using declarations |
src/Aspire.ProjectTemplates/templates/aspire-mstest/9.3/IntegrationTest1.cs | Added TestContext property and updated to use framework cancellation token plus using declarations |
Comments suppressed due to low confidence (2)
src/Aspire.ProjectTemplates/templates/aspire-xunit/9.4/IntegrationTest1.cs
Outdated
Show resolved
Hide resolved
src/Aspire.ProjectTemplates/templates/aspire-nunit/9.4/IntegrationTest1.cs
Outdated
Show resolved
Hide resolved
LGTM save the errors copilot pointed out above. |
I think it would be fine if you like to only update the 9.4 ones. The 9.3 ones will go away soon. |
@dotnet-policy-service agree |
We do uncomment and run the tests in the individual test templates. And they are failing with |
src/Aspire.ProjectTemplates/templates/aspire-nunit/9.3/IntegrationTest1.cs
Outdated
Show resolved
Hide resolved
src/Aspire.ProjectTemplates/templates/aspire-xunit/9.3/IntegrationTest1.cs
Outdated
Show resolved
Hide resolved
…tionTest1.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Description
Updating the Test Templates to properly dispose of resources used (Cancellation Token, HttpRequest, HttpResponse). We should ensure our templates use best practices. These were changes I needed to make before checking in to my own project.
Updated MSTest Template to leverage the CancellationToken from TestContext, XUnit Template already does this.
Fixes # (issue)
Checklist
<remarks />
and<code />
elements on your triple slash comments?doc-idea
templatebreaking-change
templatediagnostic
template