Skip to content

Commit 37da482

Browse files
authored
Move Blazor Server template tests to new project (#21345)
1 parent 3bd9d38 commit 37da482

25 files changed

+2187
-30
lines changed

src/Components/Web.JS/dist/Release/blazor.server.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.json diff
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using Microsoft.AspNetCore.E2ETesting;
5+
using Microsoft.AspNetCore.Testing;
6+
using Templates.Test.Helpers;
7+
using Xunit;
8+
9+
[assembly: TestFramework("Microsoft.AspNetCore.E2ETesting.XunitTestFrameworkWithAssemblyFixture", "BlazorTemplates.Tests")]
10+
11+
[assembly: Microsoft.AspNetCore.E2ETesting.AssemblyFixture(typeof(ProjectFactoryFixture))]
12+
[assembly: Microsoft.AspNetCore.E2ETesting.AssemblyFixture(typeof(SeleniumStandaloneServer))]
13+
14+
[assembly: QuarantinedTest("Investigation pending in https://github.com/dotnet/aspnetcore/issues/20479")]

src/ProjectTemplates/test/BlazorServerTemplateTest.cs renamed to src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public BlazorServerTemplateTest(ProjectFactoryFixture projectFactory, BrowserFix
2525
public Project Project { get; private set; }
2626

2727
[ConditionalFact(Skip = "This test ran for over an hour")]
28-
[SkipOnHelix("selenium")]
2928
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/20172")]
3029
public async Task BlazorServerTemplateWorks_NoAuth()
3130
{
@@ -84,7 +83,6 @@ public async Task BlazorServerTemplateWorks_NoAuth()
8483
[Theory]
8584
[InlineData(true)]
8685
[InlineData(false)]
87-
[SkipOnHelix("Selenium not supported on Helix.")]
8886
[QuarantinedTest]
8987
public async Task BlazorServerTemplateWorks_IndividualAuth(bool useLocalDB)
9088
{
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<!-- Shared testing infrastructure for running E2E tests using selenium -->
4+
<Import Project="$(SharedSourceRoot)E2ETesting\E2ETesting.props" />
5+
6+
<PropertyGroup>
7+
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
8+
<TestGroupName>ProjectTemplates.E2ETests</TestGroupName>
9+
<DefineConstants>$(DefineConstants);XPLAT</DefineConstants>
10+
11+
<RunTemplateTests Condition="'$(RunTemplateTests)' == ''" >true</RunTemplateTests>
12+
<!--Do not run this test project on Helix.-->
13+
<BuildHelixPayload>false</BuildHelixPayload>
14+
<SkipHelixArm>true</SkipHelixArm>
15+
16+
<BaseOutputPath />
17+
<OutputPath />
18+
19+
<!-- Properties that affect test runs -->
20+
<!-- TestTemplateCreationFolder is the folder where the templates will be created. Will point out to $(OutputDir)$(TestTemplateCreationFolder) -->
21+
<TestTemplateCreationFolder>TestTemplates\</TestTemplateCreationFolder>
22+
<TestPackageRestorePath>$([MSBuild]::EnsureTrailingSlash('$(RepoRoot)'))obj\template-restore\</TestPackageRestorePath>
23+
<TestTemplateTestsProps>TemplateTests.props</TestTemplateTestsProps>
24+
<GenerateLoggingTestingAssemblyAttributes>false</GenerateLoggingTestingAssemblyAttributes>
25+
<TestDependsOnAspNetRuntime>true</TestDependsOnAspNetRuntime>
26+
</PropertyGroup>
27+
28+
<ItemGroup>
29+
<EmbeddedResource Include="template-baselines.json" />
30+
<Compile Include="$(SharedSourceRoot)Process\*.cs" LinkBase="shared\Process" />
31+
</ItemGroup>
32+
33+
<ItemGroup>
34+
<ProjectReference Include="$(RepoRoot)src\Framework\src\Microsoft.AspNetCore.App.Runtime.csproj">
35+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
36+
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
37+
</ProjectReference>
38+
<ProjectReference Include="$(RepoRoot)src\Hosting\Server.IntegrationTesting\src\Microsoft.AspNetCore.Server.IntegrationTesting.csproj" />
39+
<ProjectReference Include="../testassets/DotNetToolsInstaller/DotNetToolsInstaller.csproj" ReferenceOutputAssembly="false" />
40+
<ProjectReference Include="../Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj" ReferenceOutputAssembly="false" />
41+
</ItemGroup>
42+
43+
<PropertyGroup>
44+
<PreserveExistingLogsInOutput Condition="'$(PreserveExistingLogsInOutput)' == '' AND '$(ContinuousIntegrationBuild)' == 'true'">true</PreserveExistingLogsInOutput>
45+
<PreserveExistingLogsInOutput Condition="'$(PreserveExistingLogsInOutput)' == ''">false</PreserveExistingLogsInOutput>
46+
</PropertyGroup>
47+
48+
<ItemGroup>
49+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
50+
<_Parameter1>DotNetEfFullPath</_Parameter1>
51+
<_Parameter2>$([MSBuild]::EnsureTrailingSlash('$(NuGetPackageRoot)'))dotnet-ef/$(DotnetEfPackageVersion)/tools/netcoreapp3.1/any/dotnet-ef.dll</_Parameter2>
52+
</AssemblyAttribute>
53+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
54+
<_Parameter1>TestPackageRestorePath</_Parameter1>
55+
<_Parameter2>$(TestPackageRestorePath)</_Parameter2>
56+
</AssemblyAttribute>
57+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
58+
<_Parameter1>Test.DefaultTargetFramework</_Parameter1>
59+
<_Parameter2>$(DefaultNetCoreTargetFramework)</_Parameter2>
60+
</AssemblyAttribute>
61+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(ContinuousIntegrationBuild)' == 'true'">
62+
<_Parameter1>ContinuousIntegrationBuild</_Parameter1>
63+
<_Parameter2>true</_Parameter2>
64+
</AssemblyAttribute>
65+
<AssemblyAttribute Include="Microsoft.AspNetCore.Testing.TestFrameworkFileLoggerAttribute">
66+
<_Parameter1>$(PreserveExistingLogsInOutput)</_Parameter1>
67+
<_Parameter2>$(TargetFramework)</_Parameter2>
68+
<_Parameter3></_Parameter3>
69+
</AssemblyAttribute>
70+
</ItemGroup>
71+
72+
<Target Name="PrepareForTest" BeforeTargets="CoreCompile" Condition="$(DesignTimeBuild) != true">
73+
<PropertyGroup>
74+
<TestTemplateCreationFolder>$([MSBuild]::NormalizePath('$(OutputPath)$(TestTemplateCreationFolder)'))</TestTemplateCreationFolder>
75+
<TestTemplateTestsProps>$(TestTemplateCreationFolder)$(TestTemplateTestsProps)</TestTemplateTestsProps>
76+
<CustomTemplateHivePath>$(TestTemplateCreationFolder)\Hives\$([System.Guid]::NewGuid())\.templateengine</CustomTemplateHivePath>
77+
</PropertyGroup>
78+
79+
<ItemGroup>
80+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
81+
<_Parameter1>ArtifactsShippingPackagesDir</_Parameter1>
82+
<_Parameter2>$(ArtifactsShippingPackagesDir)</_Parameter2>
83+
</AssemblyAttribute>
84+
85+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
86+
<_Parameter1>ArtifactsLogDir</_Parameter1>
87+
<_Parameter2>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'log'))</_Parameter2>
88+
</AssemblyAttribute>
89+
90+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
91+
<_Parameter1>ArtifactsNonShippingPackagesDir</_Parameter1>
92+
<_Parameter2>$(ArtifactsNonShippingPackagesDir)</_Parameter2>
93+
</AssemblyAttribute>
94+
95+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
96+
<_Parameter1>TestTemplateCreationFolder</_Parameter1>
97+
<_Parameter2>$(TestTemplateCreationFolder)</_Parameter2>
98+
</AssemblyAttribute>
99+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
100+
<_Parameter1>CustomTemplateHivePath</_Parameter1>
101+
<_Parameter2>$(CustomTemplateHivePath)</_Parameter2>
102+
</AssemblyAttribute>
103+
</ItemGroup>
104+
105+
<Message Importance="high" Text="Preparing environment for tests" />
106+
<!-- Remove the template creation folders and the package-restore folders to ensure that when we run the tests we don't
107+
get cached results and changes show up.
108+
-->
109+
110+
<ItemGroup>
111+
<_ExistingFilesFromLastRun Include="$(TestTemplateCreationFolder)**\*" />
112+
</ItemGroup>
113+
114+
<Delete Files="@(_ExistingFilesFromLastRun)" ContinueOnError="true" />
115+
116+
<Removedir Directories="$(TestTemplateCreationFolder)" Condition="Exists('$(TestTemplateCreationFolder)')" ContinueOnError="true">
117+
<Output TaskParameter="RemovedDirectories" ItemName="_CleanedUpDirectories" />
118+
</Removedir>
119+
<Removedir Directories="$(TestPackageRestorePath)" Condition="Exists('$(TestPackageRestorePath)')" ContinueOnError="true">
120+
<Output TaskParameter="RemovedDirectories" ItemName="_CleanedUpDirectories" />
121+
</Removedir>
122+
123+
<Message Importance="high" Text="Removed directory %(_CleanedUpDirectories.Identity)" />
124+
125+
<MakeDir Directories="$(TestTemplateCreationFolder)">
126+
<Output TaskParameter="DirectoriesCreated" ItemName="_CreatedDirectories" />
127+
</MakeDir>
128+
<MakeDir Directories="$(TestPackageRestorePath)">
129+
<Output TaskParameter="DirectoriesCreated" ItemName="_CreatedDirectories" />
130+
</MakeDir>
131+
132+
<Message Importance="high" Text="Created directory %(_CreatedDirectories.Identity)" />
133+
134+
<GenerateFileFromTemplate
135+
TemplateFile="$(MSBuildThisFileDirectory)Infrastructure\Directory.Build.targets.in"
136+
Properties="TemplateTestsPropsPath=$(TestTemplateTestsProps)"
137+
OutputPath="$(TestTemplateCreationFolder)Directory.Build.targets" />
138+
139+
<GenerateFileFromTemplate
140+
TemplateFile="$(MSBuildThisFileDirectory)Infrastructure\Directory.Build.props.in"
141+
Properties=""
142+
OutputPath="$(TestTemplateCreationFolder)Directory.Build.props" />
143+
144+
<!-- Workaround https://github.com/dotnet/core-setup/issues/6420 - there is no MSBuild setting for rollforward yet -->
145+
<Copy SourceFiles="$(MSBuildThisFileDirectory)Infrastructure\runtimeconfig.norollforward.json" DestinationFolder="$(TestTemplateCreationFolder)" UseHardLinksIfPossible="true" />
146+
147+
<Delete Files="$(TestTemplateTestsProps)" />
148+
149+
</Target>
150+
151+
<!-- Shared testing infrastructure for running E2E tests using selenium -->
152+
<Import Project="$(SharedSourceRoot)E2ETesting\E2ETesting.targets" />
153+
154+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.targets))\Directory.Build.targets" />
3+
<Import Project="$(MSBuildThisFileDirectory)Infrastructure\GenerateTestProps.targets" />
4+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project>
2+
<!-- This file gets copied above the template test projects so that we disconnect the templates from the rest of the repository -->
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp5.0</TargetFramework>
5+
</PropertyGroup>
6+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project>
2+
<Import Project="${TemplateTestsPropsPath}" />
3+
</Project>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<Project>
2+
<Target Name="GenerateTestProps"
3+
BeforeTargets="CoreCompile"
4+
DependsOnTargets="PrepareForTest"
5+
Condition="$(DesignTimeBuild) != true">
6+
<!-- The version of the shared framework. This is used in tests to ensure they run against the shared framework version we just built. -->
7+
<!-- If we aren't building the targeting pack, use the baseline version -->
8+
<MSBuild Projects="$(RepoRoot)src\Framework\ref\Microsoft.AspNetCore.App.Ref.csproj"
9+
Targets="_GetPackageVersionInfo"
10+
SkipNonexistentProjects="false"
11+
Condition="'$(IsTargetingPackBuilding)' != 'false'">
12+
<Output TaskParameter="TargetOutputs" ItemName="_TargetingPackVersionInfo" />
13+
</MSBuild>
14+
15+
<!-- Targeting pack version should be the one we just built, if we're building it. Otherwise we use the baseline version -->
16+
<PropertyGroup>
17+
<MicrosoftAspNetCoreAppRefPackageVersion Condition="'$(IsTargetingPackBuilding)' != 'false'">%(_TargetingPackVersionInfo.PackageVersion)</MicrosoftAspNetCoreAppRefPackageVersion>
18+
<MicrosoftAspNetCoreAppRefPackageVersion Condition="'$(IsTargetingPackBuilding)' == 'false'">$(TargetingPackVersionPrefix)</MicrosoftAspNetCoreAppRefPackageVersion>
19+
</PropertyGroup>
20+
21+
<!-- Runtime and Ref packs may have separate versions. -->
22+
<MSBuild Projects="$(RepoRoot)src\Framework\src\Microsoft.AspNetCore.App.Runtime.csproj"
23+
Targets="_GetPackageVersionInfo"
24+
SkipNonexistentProjects="false">
25+
<Output TaskParameter="TargetOutputs" ItemName="_RuntimePackageVersionInfo" />
26+
</MSBuild>
27+
28+
<PropertyGroup>
29+
<PropsProperties>
30+
RestoreAdditionalProjectSources=$([MSBuild]::Escape("$(RestoreAdditionalProjectSources);$(ArtifactsShippingPackagesDir);$(ArtifactsNonShippingPackagesDir)"));
31+
MicrosoftNetCompilersToolsetPackageVersion=$(MicrosoftNetCompilersToolsetPackageVersion);
32+
MicrosoftNETCoreAppRuntimeVersion=$(MicrosoftNETCoreAppRuntimeVersion);
33+
MicrosoftNETCoreAppRefPackageVersion=$(MicrosoftNETCoreAppRefPackageVersion);
34+
MicrosoftNETCorePlatformsPackageVersion=$(MicrosoftNETCorePlatformsPackageVersion);
35+
MicrosoftNETSdkRazorPackageVersion=$(MicrosoftNETSdkRazorPackageVersion);
36+
MicrosoftAspNetCoreAppRefPackageVersion=$(MicrosoftAspNetCoreAppRefPackageVersion);
37+
MicrosoftAspNetCoreAppRuntimePackageVersion=@(_RuntimePackageVersionInfo->'%(PackageVersion)');
38+
SupportedRuntimeIdentifiers=$(SupportedRuntimeIdentifiers);
39+
DefaultNetCoreTargetFramework=$(DefaultNetCoreTargetFramework);
40+
</PropsProperties>
41+
</PropertyGroup>
42+
43+
<GenerateFileFromTemplate
44+
TemplateFile="$(MSBuildThisFileDirectory)\TemplateTests.props.in"
45+
Properties="$(PropsProperties)"
46+
OutputPath="$(TestTemplateTestsProps)" />
47+
</Target>
48+
</Project>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<Project>
2+
<PropertyGroup>
3+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
4+
<RestoreAdditionalProjectSources>${RestoreAdditionalProjectSources}</RestoreAdditionalProjectSources>
5+
6+
<!-- This sets an option which prevents the tests from rolling forward into a newer shared framework. -->
7+
<UserRuntimeConfig>$(MSBuildThisFileDirectory)runtimeconfig.norollforward.json</UserRuntimeConfig>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<KnownFrameworkReference
12+
Update="Microsoft.NETCore.App"
13+
DefaultRuntimeFrameworkVersion="${MicrosoftNETCoreAppRuntimeVersion}"
14+
LatestRuntimeFrameworkVersion="${MicrosoftNETCoreAppRuntimeVersion}"
15+
TargetingPackVersion="${MicrosoftNETCoreAppRefPackageVersion}" />
16+
17+
<KnownFrameworkReference
18+
Update="Microsoft.AspNetCore.App"
19+
DefaultRuntimeFrameworkVersion="${MicrosoftAspNetCoreAppRuntimePackageVersion}"
20+
LatestRuntimeFrameworkVersion="${MicrosoftAspNetCoreAppRuntimePackageVersion}"
21+
TargetingPackVersion="${MicrosoftAspNetCoreAppRefPackageVersion}"
22+
RuntimePackRuntimeIdentifiers="${SupportedRuntimeIdentifiers}" />
23+
</ItemGroup>
24+
25+
<ItemGroup>
26+
<PackageReference Include="Microsoft.Net.Compilers.Toolset"
27+
Version="${MicrosoftNetCompilersToolsetPackageVersion}"
28+
PrivateAssets="all"
29+
IsImplicitlyDefined="true" />
30+
</ItemGroup>
31+
32+
<ItemGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''">
33+
<!--
34+
Use the Razor SDK as a package reference. The version of the .NET Core SDK we build with often contains a version of the Razor SDK
35+
several versions older than latest. To avoid a cyclical dependency, this package reference is added to override the bundled version.
36+
-->
37+
<PackageReference Include="Microsoft.NET.Sdk.Razor" PrivateAssets="All" Version="${MicrosoftNETSdkRazorPackageVersion}" />
38+
</ItemGroup>
39+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"rollForward": "Disable"
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
// We give each Selenium test assertion up to two minutes to fail before any other test in the
3+
// build has failed
4+
"DefaultWaitTimeoutInSeconds": 120,
5+
// This value is balanced between completing the build fast enough upon failure and giving
6+
// each E2E test a fair chance to pass even in the event that a separate test has failed already.
7+
"DefaultAfterFailureWaitTimeoutInSeconds": 120
8+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"DefaultWaitTimeoutInSeconds": 20,
3+
"ScreenShotsPath": "../../screenshots"
4+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "microsoft.aspnetcore.projecttemplates.tests",
3+
"version": "0.0.1",
4+
"description": "Not a real package. This file exists only to declare dependencies.",
5+
"main": "index.js",
6+
"private": true,
7+
"scripts": {
8+
"selenium-standalone": "selenium-standalone",
9+
"prepare": "selenium-standalone install --config ../../Shared/E2ETesting/selenium-config.json"
10+
},
11+
"author": "",
12+
"license": "Apache-2.0",
13+
"dependencies": {
14+
"selenium-standalone": "^6.17.0"
15+
}
16+
}

0 commit comments

Comments
 (0)