Skip to content
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

Merged
merged 8 commits into from
Mar 15, 2024

Conversation

DamianEdwards
Copy link
Member

@DamianEdwards DamianEdwards commented Mar 14, 2024

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.

image

image

image

Fixes #579

Microsoft Reviewers: Open in CodeFlow

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-codeflow for labeling automated codeflow. intentionally a different color! label Mar 14, 2024
@phenning
Copy link
Contributor

phenning commented Mar 15, 2024 via email

@DamianEdwards
Copy link
Member Author

@phenning thanks, I've logged #2924 to follow up.

Copy link
Member

@eerhardt eerhardt left a 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!

var response = await httpClient.GetAsync("/");

// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Copy link
Member

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:

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.

Copy link
Member Author

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.

Copy link
Member

@eerhardt eerhardt Mar 15, 2024

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?

Copy link
Member Author

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.

src/Aspire.Hosting/build/Aspire.Hosting.props Outdated Show resolved Hide resolved
@DamianEdwards DamianEdwards enabled auto-merge (squash) March 15, 2024 22:32
@DamianEdwards DamianEdwards merged commit befe821 into main Mar 15, 2024
8 checks passed
@DamianEdwards DamianEdwards deleted the damianedwards/tests-template branch March 15, 2024 23:21
@github-actions github-actions bot locked and limited conversation to collaborators Apr 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-codeflow for labeling automated codeflow. intentionally a different color!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to Aspire template to create a test project that uses the AppHost
5 participants