-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add tests for test templates #49102
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add tests for test templates #49102
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
Adds a new integration test for handling incorrect host data in template installations.
- Introduces an additional test case to verify installation exit code when host data is incorrect.
- Uses a custom hive and working directory for isolation in the new test.
Comments suppressed due to low confidence (2)
test/dotnet-new.IntegrationTests/DotnetNewInstallTests.cs:608
- The test method name ends with '1', which is ambiguous. Consider renaming it to reflect the specific scenario being tested, e.g.,
CanInstall_WhenHostDataIsIncorrect
.
public void CanShowWarning_WhenHostDataIsIncorrect1()
test/dotnet-new.IntegrationTests/DotnetNewInstallTests.cs:615
- This assertion only checks the exit code. To fully validate the behavior for incorrect host data, add assertions for expected warning messages in stdout or stderr.
.Should().ExitWith(0);
|
||
private static readonly ImmutableArray<string> SupportedTargetFrameworks = | ||
[ | ||
"net10.0", |
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.
Did you want to target any downlevel versions? In net11, would these tests target net11 and net10 or be updated to just net11? If you're only ever going to target current, you might be able to reuse the values in ToolsetInfo.cs so as to reduce the work needed when upgrading TFMs.
]; | ||
|
||
private static readonly (string ProjectTemplateName, string ItemTemplateName, string[] Languages, bool SupportsTestingPlatform)[] AvailableItemTemplates = | ||
[ |
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.
How will you make sure you add any new ones here that get added in the future? Is this going to be documented somewhere?
static DotnetNewTestTemplatesTests() | ||
{ | ||
string templatePackagePath = Path.Combine( | ||
RepoTemplatePackages, |
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.
You've confirmed that this is the live location in the build, correct? I think it is but just double checking it's not the stage 0 (global.json) one as that version of templates is usually a month behind.
|
||
var dummyLog = new NullTestOutputHelper(); | ||
|
||
new DotnetNewCommand(dummyLog, "uninstall", templatePackagePath) |
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.
Help me understand why you uninstall first? Just to ensure the install works if it was already installed?
.WithCustomHive(CreateTemporaryFolder(folderName: "Home")) | ||
.WithWorkingDirectory(CreateTemporaryFolder()) | ||
.Execute() | ||
.Should().ExitWith(0); |
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.
nit: Can use .Pass() to be a bit more obvious
.WithCustomHive(outputDirectory).WithRawArguments() | ||
.WithWorkingDirectory(workingDirectory) | ||
.Execute() | ||
.Should().ExitWith(0); |
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.
same nit on Pass()
.WithCustomHive(outputDirectory).WithRawArguments() | ||
.WithWorkingDirectory(workingDirectory) | ||
.Execute() | ||
.Should().ExitWith(0); |
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.
same nit
result.Should().ExitWith(0); | ||
|
||
result.StdOut.Should().Contain("Passed!"); | ||
result.StdOut.Should().MatchRegex(@"Passed:\s*2"); |
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.
There are two tests that run?
This pull request introduces a new test suite for validating
.NET
project and item templates in thetest/dotnet-new.IntegrationTests/DotnetNewTestTemplatesTests.cs
file. The changes include adding comprehensive tests for template installation, compatibility across languages, and integration with testing platforms.Additions to Template Testing:
DotnetNewTestTemplatesTests
to test.NET
project and item templates, including their installation and test execution.SupportedTargetFrameworks
,AvailableItemTemplates
, andAvailableProjectTemplates
for defining supported frameworks and templates.ItemTemplate_CanBeInstalledAndTestArePassing
: Verifies that item templates can be installed and pass tests for various languages and frameworks.ProjectTemplate_CanBeInstalledAndTestsArePassing
: Validates project templates' installation and test execution.MSTestAndPlaywrightProjectTemplate_WithCoverageToolAndTestRunner_CanBeInstalledAndTestsArePassing
: Tests integration of project templates with coverage tools and test runners.Utility Enhancements:
AddItemToFsproj
: Handles adding F# items to `.fsproj