-
Notifications
You must be signed in to change notification settings - Fork 417
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
Add templates for Aspire test projects #2905
Conversation
src/Aspire.ProjectTemplates/templates/aspire-xunit/IntegrationTest1.cs
Outdated
Show resolved
Hide resolved
Damian, let’s talk next week if we want to consider detecting if the integration test template is installed at initial project creation and giving an option in NPD to create it then. We could set the reference and IVT upfront at project creation.
In anticipation of this, we might want to consider an option to suppress outputting the instructional text.
|
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.
Just a couple minor comments. This looks good to me. Thanks!
...spire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication.1.Tests/WebTests.cs
Show resolved
Hide resolved
var response = await httpClient.GetAsync("/"); | ||
|
||
// Assert | ||
Assert.Equal(HttpStatusCode.OK, response.StatusCode); |
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.
A nice thing we do in our tests is:
aspire/tests/Aspire.EndToEnd.Tests/IntegrationServicesTests.cs
Lines 38 to 41 in 9073e07
var response = await _integrationServicesFixture.IntegrationServiceA.HttpGetAsync("http", $"/{resourceName}/verify"); | |
var responseContent = await response.Content.ReadAsStringAsync(); | |
Assert.True(response.IsSuccessStatusCode, responseContent); |
That way if it fails, you get the responseContent logged.
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.
Because we have resiliency on the HttpClient returned from CreateHttpClient, you can't actually do it quite like that, as if the status code wasn't a success status code, it will retry until it fails anyway. I think keeping this test in the template simple is probably best for now.
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.
Doesn't resilience only retry on certain failures? If a service returns 500 (Internal Server Error), it wouldn't retry that, would it?
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.
Actually I'm not sure, I thought a 500 is exactly the kind of thing it would retry, vs. a 300 or 400 status code. Obviously connection level issues would be retried too.
Adds an option to the Aspire Starter App solution template for creating a tests project, as well as a new standalone Aspire tests project template.
Fixes #579
Microsoft Reviewers: Open in CodeFlow