-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add tests for test templates #49055
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 tests for test templates #49055
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 introduces a new acceptance test project to the .NET SDK solution to validate that project and item templates can be installed and executed correctly via the dotnet
CLI. It adds the test project’s .csproj
to the solution, implements utility helpers, and provides end-to-end tests for various templates across supported languages and frameworks.
- Adds
Microsoft.TestTemplates.Acceptance.Tests
project and wires it intosdk.sln
- Implements helper classes (
DotnetUtils
,ExecutionResult
,Constants
,Languages
) for invoking and validatingdotnet
commands - Adds
AcceptanceTests
suite covering project and item template installation, test execution, and cleanup
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
test/Microsoft.TestTemplates.Acceptance.Tests/Microsoft.TestTemplates.Acceptance.Tests.csproj | Defines the new test project, references, and copy target |
test/Microsoft.TestTemplates.Acceptance.Tests/Languages.cs | Introduces supported language constants |
test/Microsoft.TestTemplates.Acceptance.Tests/ExecutionResult.cs | Captures CLI execution results and provides validation |
test/Microsoft.TestTemplates.Acceptance.Tests/DotnetUtils.cs | Helper methods to invoke dotnet CLI commands |
test/Microsoft.TestTemplates.Acceptance.Tests/Constants.cs | Configuration constants, repo-root discovery logic |
test/Microsoft.TestTemplates.Acceptance.Tests/AcceptanceTests.cs | End-to-end acceptance tests for templates |
sdk.sln | Registers the new acceptance tests project |
Comments suppressed due to low confidence (1)
test/Microsoft.TestTemplates.Acceptance.Tests/AcceptanceTests.cs:158
- Inserting XML by string matching is brittle. Consider using an XML DOM parser (e.g.,
XDocument
) to locate the<ItemGroup>
and insert the<Compile>
element more robustly.
lines.Insert(lines.IndexOf(" <ItemGroup>") + 1, $" <Compile Include=\"{itemName}.fs\"/>");
test/Microsoft.TestTemplates.Acceptance.Tests/ExecutionResult.cs
Outdated
Show resolved
Hide resolved
…github.com/dotnet/sdk into dev/mabdullah/add-tests-for-test-templates
Pull request was closed
This pull request introduces a new test project,
Microsoft.TestTemplates.Acceptance.Tests
, into the solution. It includes updates to the solution file (sdk.sln
) to register the new project, and adds several new files implementing acceptance tests, utilities, and constants for the test framework. The key changes are grouped and summarized below:Solution Updates:
Microsoft.TestTemplates.Acceptance.Tests
to the solution filesdk.sln
, including its configuration for Debug and Release builds. [1] [2]New Test Project Implementation:
AcceptanceTests.cs
to define acceptance tests for validating the installation and execution of project and item templates usingdotnet new
anddotnet test
. The tests cover various frameworks, languages, and configurations.Constants.cs
to centralize shared constants, such as the build configuration and temporary artifacts directory.DotnetUtils.cs
to encapsulate utility methods for invokingdotnet
commands, including template installation, uninstallation, and test execution.ExecutionResult.cs
to represent the result ofdotnet
command executions and provide extensions for validating test outcomes.This will be followed be a PR where those test projects will be built and run via pipelines for CG (Component Governance).