dotnet / templating

This repo contains the Template Engine which is used by dotnet new
https://docs.microsoft.com/dotnet/
MIT License
1.64k stars 369 forks source link

SDK templates testing in dotnet/installer #6026

Open donJoseLuis opened 1 year ago

donJoseLuis commented 1 year ago

Improving template tests in dotnet/installer

Background

One of the most common problems with .NET templates shipped within .NET SDK are the issues which defining grouping metadata: identity, group identity, precedence. This issue is commonly reproduced only when multiple .NET SDKs are installed. Invalid definition results in the conflict that is shown only when the template is attempted to be run and the user cannot resolve it.

During delivery of .NET 5 test templates and common templates had this issue. During delivery of .NET 6 ASP.NET templates and WPF templates had this issue. Issue with item templates in asp.net was discovered post preview 7.

The problem is amplified because the templates are delivered by 5 teams as of now, using different approaches for authoring, infrastructure and testing their templates. dotnet/installer seems to be the only common point for them.

Proposal

Since the dotnet/installer is the first and last point where the template packages are inserted, create the tests that can catch the issues described above and disallow releasing the build until they are solved. The tests will be written by template engine team, the maintenance of them may be negotiated between template engine team, dotnet/installer team or template authors.

Technical details

The tests are suggested as the separate job in existing pipeline. Running tests on a single platform is enough - should the issue occur, it is identically reproduced on all the platforms.

The tests will do the following actions:

Preparation steps:

Test action:

There are 2 ways how to ensure the test matrix:

Planned number of test cases (maximum): 40 templates x 2 languages (average) x 4 TFMs = 320 cases. Note: it is a maximum number of tests as not all the templates support all the frameworks.

Predicted test run time: 320 cases * 2 sec = 640 sec ~ 11 minutes Note: doesn't include build, test preparation steps, test matrix preparation.

Other possible improvements:

Tasks

Justification

Engineering Impact

  1. Time savings from streamlined test execution in the installer pipelines.
vlada-shubina commented 1 year ago

From https://github.com/dotnet/templating/issues/5463

Would it be possible to include concrete examples of the issues described in the Background section? Have there been cases where a template was successfully run (in terms of output and exit code) but the generated artifacts had a bug?

Concrete examples from .NET 7 https://github.com/dotnet/wpf/issues/7204#issuecomment-1279465226 https://github.com/dotnet/aspnetcore/pull/44479 https://github.com/dotnet/aspnetcore/issues/44095 https://github.com/dotnet/test-templates/pull/118

.NET 6: https://github.com/dotnet/templating/issues/4296 https://github.com/dotnet/templating/pull/4299 https://github.com/dotnet/test-templates/pull/118