Skip to content

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

Closed
wants to merge 22 commits into from

Conversation

mariam-abdulla
Copy link
Member

@mariam-abdulla mariam-abdulla commented May 19, 2025

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:

  • Added the new project Microsoft.TestTemplates.Acceptance.Tests to the solution file sdk.sln, including its configuration for Debug and Release builds. [1] [2]
  • Updated project dependencies and relationships in the solution file to integrate the new test project. [1] [2] [3]

New Test Project Implementation:

  • Added AcceptanceTests.cs to define acceptance tests for validating the installation and execution of project and item templates using dotnet new and dotnet test. The tests cover various frameworks, languages, and configurations.
  • Introduced Constants.cs to centralize shared constants, such as the build configuration and temporary artifacts directory.
  • Created DotnetUtils.cs to encapsulate utility methods for invoking dotnet commands, including template installation, uninstallation, and test execution.
  • Added ExecutionResult.cs to represent the result of dotnet 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).

@Copilot Copilot AI review requested due to automatic review settings May 19, 2025 15:26
Copy link
Contributor

@Copilot Copilot AI left a 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 into sdk.sln
  • Implements helper classes (DotnetUtils, ExecutionResult, Constants, Languages) for invoking and validating dotnet 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\"/>");

@mariam-abdulla mariam-abdulla enabled auto-merge (squash) May 21, 2025 09:53
auto-merge was automatically disabled May 22, 2025 14:25

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants