Skip to content

[tests] workload tests for test project templates#4240

Merged
radical merged 13 commits intomicrosoft:mainfrom
radical:workload-tests-follow-up
Jun 19, 2024
Merged

[tests] workload tests for test project templates#4240
radical merged 13 commits intomicrosoft:mainfrom
radical:workload-tests-follow-up

Conversation

@radical
Copy link
Copy Markdown
Member

@radical radical commented May 21, 2024

  • Add tests for test framework specific templates - aspire-xunit, aspire-nunit, and aspire-mstest.
  • Also, test these with different project names to validate the generated code
  • And add a test for validating a aspire-starter template with the various project names
  • The tests revealed a missing using in the test cs file, fixed here
Microsoft Reviewers: Open in CodeFlow

@ghost ghost added the area-integrations Issues pertaining to Aspire Integrations packages label May 21, 2024
@radical radical force-pushed the workload-tests-follow-up branch from 4dd5cee to c7364bc Compare May 30, 2024 05:52
@radical
Copy link
Copy Markdown
Member Author

radical commented Jun 15, 2024

@DamianEdwards the xunit test file in the template seems to be broken. I think this should fix it.

edd5812 (#4240)

The test failures: https://dev.azure.com/dnceng-public/public/_build/results?buildId=708682&view=ms.vss-test-web.build-test-results-tab

@radical radical force-pushed the workload-tests-follow-up branch from 842b3c1 to e914e75 Compare June 17, 2024 18:34
radical added 3 commits June 17, 2024 16:56
```
... testroot/aspire-aspire-xunit/aspire-aspire-xunit.aspire-xunitTests/IntegrationTest1.cs(21,27): error CS1061:
'IServiceCollection' does not contain a definition for 'ConfigureHttpClientDefaults' and no accessible extension method 'ConfigureHttpClientDefaults' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?) [/datadisks/disk1/work/B74F0975/t/testroot/aspire-aspire-xunit/aspire-aspire-xunit.aspire-xunitTests/aspire-aspire-xunit.aspire-xunitTests.csproj]
```
@radical radical force-pushed the workload-tests-follow-up branch from e914e75 to ee6ed0a Compare June 17, 2024 20:59
@radical radical requested a review from DamianEdwards June 17, 2024 20:59
@radical radical marked this pull request as ready for review June 17, 2024 20:59
@radical radical requested review from eerhardt and joperezr June 17, 2024 20:59
@radical radical changed the title [tests] Additional workload tests [tests] workload tests for test framework templates Jun 17, 2024
@radical radical changed the title [tests] workload tests for test framework templates [tests] workload tests for test project templates Jun 17, 2024
Comment thread tests/Shared/Aspire.Workload.Testing.props
}

var files = Directory.EnumerateFiles(SourceDirectory, "*.csproj", SearchOption.AllDirectories);
PackageNames = files.Where(f => File.ReadAllText(f).Contains("<IsPackable>true</IsPackable>"))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would break if we move the IsPackable to a Directory.Build.props file, right? I wonder if instead of using an inline task if it's best to just use MSBuild task for all of these projects and call a target that just returns the value of IsPackable. We don't have to do it that way but I just think that would probably be more future proof and resilient against refactorings.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! Changed.

Copy link
Copy Markdown
Member

@joperezr joperezr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left couple of suggestions, but looks good otherwise.


<!-- check against an arbitrary minimum limit to catch any issues getting the list of packages -->
<Error Text="Too few packages? count: @(ExpectedPackageNames->Count())"
Condition="@(ExpectedPackageNames->Count()) &lt; 60"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are already shipping over 60 packages from this repo? Wow.

Comment thread tests/Aspire.Workload.Tests/WorkloadTestsBase.cs Outdated
Comment on lines +189 to +200
// ActiveIssue for windows: https://github.com/dotnet/aspire/issues/4555
yield return "aspire_龦唉丂荳_㐁ᠭ_ᠤསྲིདخەلꌠ_1ᥕ";
}

// ActiveIssue: https://github.com/dotnet/aspire/issues/4550
// yield return "aspire sta-rter.test"; // Issue: two spaces

yield return "aspire_starter.1period then.34letters";
yield return "aspire-starter & with.1";

// ActiveIssue: https://github.com/dotnet/aspnetcore/issues/56277
// yield return "aspire_😀";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow - this is catching a lot of bugs. 😄

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think falls under "naming is one of the hardest problems in computer science" right? 😉

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the curious this might be a bug in the template engine - dotnet/sdk#41667 !


if (inTest && CommentLineRegex().IsMatch(line))
{
sb.AppendLine(CommentLineRegex().Replace(line, " "));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully we don't ever add real comments to the code, or else this would start failing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol! Yeah, but that would cause a failure on the PR, and then that person gets to figure it out :/

Comment thread tests/Aspire.Workload.Tests/PerTestFrameworkTemplatesTests.cs Outdated
radical and others added 4 commits June 18, 2024 20:23
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
.. packable, instead of a custom task. Doing this instead of a custom
task looking for a `<IsPackable>true</IsPackable>` string is better
because it would not be affected by refactorings, or the property being set
elsewhere.

Suggestion from @jopererz .
@radical radical merged commit 95aca25 into microsoft:main Jun 19, 2024
@radical radical deleted the workload-tests-follow-up branch June 19, 2024 03:12
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-integrations Issues pertaining to Aspire Integrations packages testing ☑️

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants