Skip to content

Move Blazor Server template tests to new project #21345

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

Merged
merged 1 commit into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Components/Web.JS/dist/Release/blazor.server.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/ProjectTemplates/BlazorTemplates.Tests/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.json diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.AspNetCore.E2ETesting;
using Microsoft.AspNetCore.Testing;
using Templates.Test.Helpers;
using Xunit;

[assembly: TestFramework("Microsoft.AspNetCore.E2ETesting.XunitTestFrameworkWithAssemblyFixture", "BlazorTemplates.Tests")]

[assembly: Microsoft.AspNetCore.E2ETesting.AssemblyFixture(typeof(ProjectFactoryFixture))]
[assembly: Microsoft.AspNetCore.E2ETesting.AssemblyFixture(typeof(SeleniumStandaloneServer))]

[assembly: QuarantinedTest("Investigation pending in https://github.com/dotnet/aspnetcore/issues/20479")]
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public BlazorServerTemplateTest(ProjectFactoryFixture projectFactory, BrowserFix
public Project Project { get; private set; }

[ConditionalFact(Skip = "This test ran for over an hour")]
[SkipOnHelix("selenium")]
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/20172")]
public async Task BlazorServerTemplateWorks_NoAuth()
{
Expand Down Expand Up @@ -84,7 +83,6 @@ public async Task BlazorServerTemplateWorks_NoAuth()
[Theory]
[InlineData(true)]
[InlineData(false)]
[SkipOnHelix("Selenium not supported on Helix.")]
[QuarantinedTest]
public async Task BlazorServerTemplateWorks_IndividualAuth(bool useLocalDB)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<Project Sdk="Microsoft.NET.Sdk">

<!-- Shared testing infrastructure for running E2E tests using selenium -->
<Import Project="$(SharedSourceRoot)E2ETesting\E2ETesting.props" />

<PropertyGroup>
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
<TestGroupName>ProjectTemplates.E2ETests</TestGroupName>
<DefineConstants>$(DefineConstants);XPLAT</DefineConstants>

<RunTemplateTests Condition="'$(RunTemplateTests)' == ''" >true</RunTemplateTests>
<!--Do not run this test project on Helix.-->
<BuildHelixPayload>false</BuildHelixPayload>
<SkipHelixArm>true</SkipHelixArm>

<BaseOutputPath />
<OutputPath />

<!-- Properties that affect test runs -->
<!-- TestTemplateCreationFolder is the folder where the templates will be created. Will point out to $(OutputDir)$(TestTemplateCreationFolder) -->
<TestTemplateCreationFolder>TestTemplates\</TestTemplateCreationFolder>
<TestPackageRestorePath>$([MSBuild]::EnsureTrailingSlash('$(RepoRoot)'))obj\template-restore\</TestPackageRestorePath>
<TestTemplateTestsProps>TemplateTests.props</TestTemplateTestsProps>
<GenerateLoggingTestingAssemblyAttributes>false</GenerateLoggingTestingAssemblyAttributes>
<TestDependsOnAspNetRuntime>true</TestDependsOnAspNetRuntime>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="template-baselines.json" />
<Compile Include="$(SharedSourceRoot)Process\*.cs" LinkBase="shared\Process" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)src\Framework\src\Microsoft.AspNetCore.App.Runtime.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
</ProjectReference>
<ProjectReference Include="$(RepoRoot)src\Hosting\Server.IntegrationTesting\src\Microsoft.AspNetCore.Server.IntegrationTesting.csproj" />
<ProjectReference Include="../testassets/DotNetToolsInstaller/DotNetToolsInstaller.csproj" ReferenceOutputAssembly="false" />
<ProjectReference Include="../Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj" ReferenceOutputAssembly="false" />
</ItemGroup>

<PropertyGroup>
<PreserveExistingLogsInOutput Condition="'$(PreserveExistingLogsInOutput)' == '' AND '$(ContinuousIntegrationBuild)' == 'true'">true</PreserveExistingLogsInOutput>
<PreserveExistingLogsInOutput Condition="'$(PreserveExistingLogsInOutput)' == ''">false</PreserveExistingLogsInOutput>
</PropertyGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>DotNetEfFullPath</_Parameter1>
<_Parameter2>$([MSBuild]::EnsureTrailingSlash('$(NuGetPackageRoot)'))dotnet-ef/$(DotnetEfPackageVersion)/tools/netcoreapp3.1/any/dotnet-ef.dll</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>TestPackageRestorePath</_Parameter1>
<_Parameter2>$(TestPackageRestorePath)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>Test.DefaultTargetFramework</_Parameter1>
<_Parameter2>$(DefaultNetCoreTargetFramework)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(ContinuousIntegrationBuild)' == 'true'">
<_Parameter1>ContinuousIntegrationBuild</_Parameter1>
<_Parameter2>true</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="Microsoft.AspNetCore.Testing.TestFrameworkFileLoggerAttribute">
<_Parameter1>$(PreserveExistingLogsInOutput)</_Parameter1>
<_Parameter2>$(TargetFramework)</_Parameter2>
<_Parameter3></_Parameter3>
</AssemblyAttribute>
</ItemGroup>

<Target Name="PrepareForTest" BeforeTargets="CoreCompile" Condition="$(DesignTimeBuild) != true">
<PropertyGroup>
<TestTemplateCreationFolder>$([MSBuild]::NormalizePath('$(OutputPath)$(TestTemplateCreationFolder)'))</TestTemplateCreationFolder>
<TestTemplateTestsProps>$(TestTemplateCreationFolder)$(TestTemplateTestsProps)</TestTemplateTestsProps>
<CustomTemplateHivePath>$(TestTemplateCreationFolder)\Hives\$([System.Guid]::NewGuid())\.templateengine</CustomTemplateHivePath>
</PropertyGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>ArtifactsShippingPackagesDir</_Parameter1>
<_Parameter2>$(ArtifactsShippingPackagesDir)</_Parameter2>
</AssemblyAttribute>

<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>ArtifactsLogDir</_Parameter1>
<_Parameter2>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'log'))</_Parameter2>
</AssemblyAttribute>

<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>ArtifactsNonShippingPackagesDir</_Parameter1>
<_Parameter2>$(ArtifactsNonShippingPackagesDir)</_Parameter2>
</AssemblyAttribute>

<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>TestTemplateCreationFolder</_Parameter1>
<_Parameter2>$(TestTemplateCreationFolder)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>CustomTemplateHivePath</_Parameter1>
<_Parameter2>$(CustomTemplateHivePath)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>

<Message Importance="high" Text="Preparing environment for tests" />
<!-- Remove the template creation folders and the package-restore folders to ensure that when we run the tests we don't
get cached results and changes show up.
-->

<ItemGroup>
<_ExistingFilesFromLastRun Include="$(TestTemplateCreationFolder)**\*" />
</ItemGroup>

<Delete Files="@(_ExistingFilesFromLastRun)" ContinueOnError="true" />

<Removedir Directories="$(TestTemplateCreationFolder)" Condition="Exists('$(TestTemplateCreationFolder)')" ContinueOnError="true">
<Output TaskParameter="RemovedDirectories" ItemName="_CleanedUpDirectories" />
</Removedir>
<Removedir Directories="$(TestPackageRestorePath)" Condition="Exists('$(TestPackageRestorePath)')" ContinueOnError="true">
<Output TaskParameter="RemovedDirectories" ItemName="_CleanedUpDirectories" />
</Removedir>

<Message Importance="high" Text="Removed directory %(_CleanedUpDirectories.Identity)" />

<MakeDir Directories="$(TestTemplateCreationFolder)">
<Output TaskParameter="DirectoriesCreated" ItemName="_CreatedDirectories" />
</MakeDir>
<MakeDir Directories="$(TestPackageRestorePath)">
<Output TaskParameter="DirectoriesCreated" ItemName="_CreatedDirectories" />
</MakeDir>

<Message Importance="high" Text="Created directory %(_CreatedDirectories.Identity)" />

<GenerateFileFromTemplate
TemplateFile="$(MSBuildThisFileDirectory)Infrastructure\Directory.Build.targets.in"
Properties="TemplateTestsPropsPath=$(TestTemplateTestsProps)"
OutputPath="$(TestTemplateCreationFolder)Directory.Build.targets" />

<GenerateFileFromTemplate
TemplateFile="$(MSBuildThisFileDirectory)Infrastructure\Directory.Build.props.in"
Properties=""
OutputPath="$(TestTemplateCreationFolder)Directory.Build.props" />

<!-- Workaround https://github.com/dotnet/core-setup/issues/6420 - there is no MSBuild setting for rollforward yet -->
<Copy SourceFiles="$(MSBuildThisFileDirectory)Infrastructure\runtimeconfig.norollforward.json" DestinationFolder="$(TestTemplateCreationFolder)" UseHardLinksIfPossible="true" />

<Delete Files="$(TestTemplateTestsProps)" />

</Target>

<!-- Shared testing infrastructure for running E2E tests using selenium -->
<Import Project="$(SharedSourceRoot)E2ETesting\E2ETesting.targets" />

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Project>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.targets))\Directory.Build.targets" />
<Import Project="$(MSBuildThisFileDirectory)Infrastructure\GenerateTestProps.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<!-- This file gets copied above the template test projects so that we disconnect the templates from the rest of the repository -->
<PropertyGroup>
<TargetFramework>netcoreapp5.0</TargetFramework>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<Import Project="${TemplateTestsPropsPath}" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<Project>
<Target Name="GenerateTestProps"
BeforeTargets="CoreCompile"
DependsOnTargets="PrepareForTest"
Condition="$(DesignTimeBuild) != true">
<!-- The version of the shared framework. This is used in tests to ensure they run against the shared framework version we just built. -->
<!-- If we aren't building the targeting pack, use the baseline version -->
<MSBuild Projects="$(RepoRoot)src\Framework\ref\Microsoft.AspNetCore.App.Ref.csproj"
Targets="_GetPackageVersionInfo"
SkipNonexistentProjects="false"
Condition="'$(IsTargetingPackBuilding)' != 'false'">
<Output TaskParameter="TargetOutputs" ItemName="_TargetingPackVersionInfo" />
</MSBuild>

<!-- Targeting pack version should be the one we just built, if we're building it. Otherwise we use the baseline version -->
<PropertyGroup>
<MicrosoftAspNetCoreAppRefPackageVersion Condition="'$(IsTargetingPackBuilding)' != 'false'">%(_TargetingPackVersionInfo.PackageVersion)</MicrosoftAspNetCoreAppRefPackageVersion>
<MicrosoftAspNetCoreAppRefPackageVersion Condition="'$(IsTargetingPackBuilding)' == 'false'">$(TargetingPackVersionPrefix)</MicrosoftAspNetCoreAppRefPackageVersion>
</PropertyGroup>

<!-- Runtime and Ref packs may have separate versions. -->
<MSBuild Projects="$(RepoRoot)src\Framework\src\Microsoft.AspNetCore.App.Runtime.csproj"
Targets="_GetPackageVersionInfo"
SkipNonexistentProjects="false">
<Output TaskParameter="TargetOutputs" ItemName="_RuntimePackageVersionInfo" />
</MSBuild>

<PropertyGroup>
<PropsProperties>
RestoreAdditionalProjectSources=$([MSBuild]::Escape("$(RestoreAdditionalProjectSources);$(ArtifactsShippingPackagesDir);$(ArtifactsNonShippingPackagesDir)"));
MicrosoftNetCompilersToolsetPackageVersion=$(MicrosoftNetCompilersToolsetPackageVersion);
MicrosoftNETCoreAppRuntimeVersion=$(MicrosoftNETCoreAppRuntimeVersion);
MicrosoftNETCoreAppRefPackageVersion=$(MicrosoftNETCoreAppRefPackageVersion);
MicrosoftNETCorePlatformsPackageVersion=$(MicrosoftNETCorePlatformsPackageVersion);
MicrosoftNETSdkRazorPackageVersion=$(MicrosoftNETSdkRazorPackageVersion);
MicrosoftAspNetCoreAppRefPackageVersion=$(MicrosoftAspNetCoreAppRefPackageVersion);
MicrosoftAspNetCoreAppRuntimePackageVersion=@(_RuntimePackageVersionInfo->'%(PackageVersion)');
SupportedRuntimeIdentifiers=$(SupportedRuntimeIdentifiers);
DefaultNetCoreTargetFramework=$(DefaultNetCoreTargetFramework);
</PropsProperties>
</PropertyGroup>

<GenerateFileFromTemplate
TemplateFile="$(MSBuildThisFileDirectory)\TemplateTests.props.in"
Properties="$(PropsProperties)"
OutputPath="$(TestTemplateTestsProps)" />
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Project>
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<RestoreAdditionalProjectSources>${RestoreAdditionalProjectSources}</RestoreAdditionalProjectSources>

<!-- This sets an option which prevents the tests from rolling forward into a newer shared framework. -->
<UserRuntimeConfig>$(MSBuildThisFileDirectory)runtimeconfig.norollforward.json</UserRuntimeConfig>
</PropertyGroup>

<ItemGroup>
<KnownFrameworkReference
Update="Microsoft.NETCore.App"
DefaultRuntimeFrameworkVersion="${MicrosoftNETCoreAppRuntimeVersion}"
LatestRuntimeFrameworkVersion="${MicrosoftNETCoreAppRuntimeVersion}"
TargetingPackVersion="${MicrosoftNETCoreAppRefPackageVersion}" />

<KnownFrameworkReference
Update="Microsoft.AspNetCore.App"
DefaultRuntimeFrameworkVersion="${MicrosoftAspNetCoreAppRuntimePackageVersion}"
LatestRuntimeFrameworkVersion="${MicrosoftAspNetCoreAppRuntimePackageVersion}"
TargetingPackVersion="${MicrosoftAspNetCoreAppRefPackageVersion}"
RuntimePackRuntimeIdentifiers="${SupportedRuntimeIdentifiers}" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Net.Compilers.Toolset"
Version="${MicrosoftNetCompilersToolsetPackageVersion}"
PrivateAssets="all"
IsImplicitlyDefined="true" />
</ItemGroup>

<ItemGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''">
<!--
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
several versions older than latest. To avoid a cyclical dependency, this package reference is added to override the bundled version.
-->
<PackageReference Include="Microsoft.NET.Sdk.Razor" PrivateAssets="All" Version="${MicrosoftNETSdkRazorPackageVersion}" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"rollForward": "Disable"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
// We give each Selenium test assertion up to two minutes to fail before any other test in the
// build has failed
"DefaultWaitTimeoutInSeconds": 120,
// This value is balanced between completing the build fast enough upon failure and giving
// each E2E test a fair chance to pass even in the event that a separate test has failed already.
"DefaultAfterFailureWaitTimeoutInSeconds": 120
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"DefaultWaitTimeoutInSeconds": 20,
"ScreenShotsPath": "../../screenshots"
}
16 changes: 16 additions & 0 deletions src/ProjectTemplates/BlazorTemplates.Tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "microsoft.aspnetcore.projecttemplates.tests",
"version": "0.0.1",
"description": "Not a real package. This file exists only to declare dependencies.",
"main": "index.js",
"private": true,
"scripts": {
"selenium-standalone": "selenium-standalone",
"prepare": "selenium-standalone install --config ../../Shared/E2ETesting/selenium-config.json"
},
"author": "",
"license": "Apache-2.0",
"dependencies": {
"selenium-standalone": "^6.17.0"
}
}
Loading