[CI] Improve overall PR Tests time#10309
Merged
radical merged 2 commits intodotnet:mainfrom Jul 10, 2025
Merged
Conversation
The number of tests have multiplied, and it takes ~14 mins on github actions to run them. Split them up so they can run in parallel and the overall run time can come down.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the NewUpAndBuildSupportProjectTemplatesTests class by extracting a shared protected method into an abstract base class and splitting the various template configurations into separate derived test classes so they can run in parallel.
- Introduces
NewUpAndBuildSupportProjectTemplatesBase(abstract) withCanNewAndBuildActual - Creates one derived test class per template variant (NUnit, XUnit v2/v3/v3MTP, MSTest, etc.)
- Removes the monolithic
[Theory]with manyMemberDataentries and spreads them across multiple classes
Comments suppressed due to low confidence (4)
tests/Aspire.Templates.Tests/NewUpAndBuildSupportProjectTemplatesTests.cs:8
- [nitpick] The base class name ends with
Basebut doesn’t clearly signal it’s for tests. Consider renaming toNewUpAndBuildSupportProjectTemplatesTestsBasefor consistency with test naming conventions.
public abstract class NewUpAndBuildSupportProjectTemplatesBase(ITestOutputHelper testOutput) : TemplateTestsBase(testOutput)
tests/Aspire.Templates.Tests/NewUpAndBuildSupportProjectTemplatesTests.cs:64
- [nitpick] Type names with underscores diverge from .NET PascalCase conventions. Rename
NUnit_NewUpAndBuildSupportProjectTemplatesTeststo something likeNUnitNewUpAndBuildSupportProjectTemplatesTests.
public class NUnit_NewUpAndBuildSupportProjectTemplatesTests : NewUpAndBuildSupportProjectTemplatesBase
tests/Aspire.Templates.Tests/NewUpAndBuildSupportProjectTemplatesTests.cs:64
- [nitpick] There is significant duplication across the multiple derived test classes differing only by their
MemberDataargument. Consider parameterizing these variants (e.g., via a single[Theory]with combinedMemberDataor code generation) to reduce boilerplate.
public class NUnit_NewUpAndBuildSupportProjectTemplatesTests : NewUpAndBuildSupportProjectTemplatesBase
tests/Aspire.Templates.Tests/NewUpAndBuildSupportProjectTemplatesTests.cs:71
- Attribute parameters must be compile-time constants; verify that the C# collection-expression syntax (
["aspire-nunit", ""]) is valid here. If not, switch to an explicitnew object[]{ ... }initializer.
[MemberData(nameof(TestDataForNewAndBuildTemplateTests), arguments: ["aspire-nunit", ""])]
eerhardt
reviewed
Jul 10, 2025
tests/Aspire.Templates.Tests/NewUpAndBuildSupportProjectTemplatesTests.cs
Outdated
Show resolved
Hide resolved
eerhardt
approved these changes
Jul 10, 2025
…tesTests.cs Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reduces CI time from ~24mins to ~15mins.
[tests] Split NewUpAndBuildSupportProjectTemplates
The number of tests have multiplied in this class, and it takes ~14 mins on github
actions to run them. Split them up so they can run in parallel and the
overall run time can come down.