Skip to content

Commit b645478

Browse files
committed
[Templating][Components] Unify and improve E2E testing infrastructure
* Unify the Templating and Components testing infrastructure. * Enable test project discovery in the components E2E tests.
1 parent 48a67cf commit b645478

File tree

60 files changed

+1774
-587
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1774
-587
lines changed

src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using BasicTestApp;
55
using Microsoft.AspNetCore.Components;
66
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
7+
using Microsoft.AspNetCore.E2ETesting;
78
using OpenQA.Selenium;
89
using OpenQA.Selenium.Support.UI;
910
using System;

src/Components/test/E2ETest/Infrastructure/CaptureSeleniumLogsAttribute.cs

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/Components/test/E2ETest/Infrastructure/ServerFixtures/AspNetSiteServerFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -24,7 +24,7 @@ protected override IWebHost CreateWebHost()
2424
}
2525

2626
var sampleSitePath = FindSampleOrTestSitePath(
27-
BuildWebHostMethod.Method.DeclaringType.Assembly.GetName().Name);
27+
BuildWebHostMethod.Method.DeclaringType.Assembly.FullName);
2828

2929
return BuildWebHostMethod(new[]
3030
{

src/Components/test/E2ETest/Infrastructure/ServerFixtures/DevHostServerFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using Microsoft.AspNetCore.Hosting;
@@ -16,7 +16,7 @@ public class DevHostServerFixture<TProgram> : WebHostServerFixture
1616
protected override IWebHost CreateWebHost()
1717
{
1818
ContentRoot = FindSampleOrTestSitePath(
19-
typeof(TProgram).Assembly.GetName().Name);
19+
typeof(TProgram).Assembly.FullName);
2020

2121
var args = new List<string>
2222
{

src/Components/test/E2ETest/Infrastructure/ServerFixtures/ServerFixture.cs

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Generic;
66
using System.IO;
77
using System.Linq;
8+
using System.Reflection;
89
using System.Threading;
910

1011
namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures
@@ -27,26 +28,13 @@ public ServerFixture()
2728

2829
protected abstract string StartAndGetRootUri();
2930

30-
protected static string FindSolutionDir()
31-
{
32-
return FindClosestDirectoryContaining(
33-
"Components.sln",
34-
Path.GetDirectoryName(typeof(ServerFixture).Assembly.Location));
35-
}
36-
3731
private static Dictionary<string, string> FindProjects()
3832
{
39-
var solutionDir = FindSolutionDir();
40-
41-
var testAssetsDirectories = new[]
42-
{
43-
Path.Combine(solutionDir, "test", "testassets"),
44-
Path.Combine(solutionDir, "blazor", "testassets"),
45-
};
46-
47-
return testAssetsDirectories
48-
.SelectMany(d => new DirectoryInfo(d).EnumerateDirectories())
49-
.ToDictionary(d => d.Name, d => d.FullName);
33+
return typeof(ServerFixture).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
34+
.Where(m => m.Key.StartsWith("TestAssemblyApplication["))
35+
.ToDictionary(m =>
36+
m.Key.Replace("TestAssemblyApplication", "").TrimStart('[').TrimEnd(']'),
37+
m => m.Value);
5038
}
5139

5240
protected static string FindSampleOrTestSitePath(string projectName)
@@ -60,28 +48,6 @@ protected static string FindSampleOrTestSitePath(string projectName)
6048
throw new ArgumentException($"Cannot find a sample or test site with name '{projectName}'.");
6149
}
6250

63-
private static string FindClosestDirectoryContaining(
64-
string filename,
65-
string startDirectory)
66-
{
67-
var dir = startDirectory;
68-
while (true)
69-
{
70-
if (File.Exists(Path.Combine(dir, filename)))
71-
{
72-
return dir;
73-
}
74-
75-
dir = Directory.GetParent(dir)?.FullName;
76-
if (string.IsNullOrEmpty(dir))
77-
{
78-
throw new FileNotFoundException(
79-
$"Could not locate a file called '{filename}' in " +
80-
$"directory '{startDirectory}' or any parent directory.");
81-
}
82-
}
83-
}
84-
8551
protected static void RunInBackgroundThread(Action action)
8652
{
8753
var isDone = new ManualResetEvent(false);

src/Components/test/E2ETest/Infrastructure/ServerTestBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
5+
using Microsoft.AspNetCore.E2ETesting;
56
using System;
67
using Xunit;
78
using Xunit.Abstractions;

src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3+
<!-- Shared testing infrastructure for running E2E tests using selenium -->
4+
<Import Project="$(SharedSourceRoot)E2ETesting\E2ETesting.props" />
5+
36
<PropertyGroup>
47
<TargetFramework>netcoreapp3.0</TargetFramework>
5-
<DefaultItemExcludes>$(DefaultItemExcludes);node_modules\**</DefaultItemExcludes>
6-
<!-- WebDriver is not strong-named signed -->
7-
<SignAssembly>false</SignAssembly>
88

99
<!--
1010
Temporarily disabled until this runs on macOS
@@ -18,20 +18,10 @@
1818
<Compile Include="$(SharedSourceRoot)Process\**\*.cs" LinkBase="Shared" />
1919
</ItemGroup>
2020

21-
<!-- Version of this SDK is set in global.json -->
22-
<Sdk Name="Yarn.MSBuild" />
23-
24-
<Target Name="EnsureNodeJSRestored" BeforeTargets="Build" Condition="'$(BlazorAllTests)'=='true'">
25-
<Message Text="Running yarn install on $(MSBuildProjectFile)" Importance="High" />
26-
<Yarn Command="install" />
27-
</Target>
28-
2921
<ItemGroup>
3022
<Reference Include="Microsoft.AspNetCore.Hosting" />
3123
<Reference Include="Microsoft.AspNetCore.Server.Kestrel" />
3224
<Reference Include="Microsoft.AspNetCore.StaticFiles" />
33-
<Reference Include="Selenium.Support" />
34-
<Reference Include="Selenium.WebDriver" />
3525
</ItemGroup>
3626

3727
<ItemGroup>
@@ -48,4 +38,7 @@
4838
<ProjectReference Include="..\testassets\TestServer\TestServer.csproj" />
4939
</ItemGroup>
5040

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

src/Components/test/E2ETest/ServerExecutionTests/ServerComponentRenderingTest.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4+
using System;
45
using BasicTestApp;
5-
using Microsoft.AspNetCore.Components.Browser.Rendering;
6-
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
76
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
87
using Microsoft.AspNetCore.Components.E2ETest.Tests;
8+
using Microsoft.AspNetCore.E2ETesting;
99
using OpenQA.Selenium;
10-
using System;
11-
using System.Threading.Tasks;
1210
using Xunit;
1311
using Xunit.Abstractions;
1412

src/Components/test/E2ETest/ServerExecutionTests/ServerSideAppTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
55
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
6+
using Microsoft.AspNetCore.E2ETesting;
67
using OpenQA.Selenium;
78
using OpenQA.Selenium.Support.UI;
89
using System;

src/Components/test/E2ETest/ServerExecutionTests/TestSubclasses.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
66
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
77
using Microsoft.AspNetCore.Components.E2ETest.Tests;
8+
using Microsoft.AspNetCore.E2ETesting;
89
using Xunit.Abstractions;
910

1011
namespace Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests

src/Components/test/E2ETest/Tests/BinaryHttpClientTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using BasicTestApp.HttpClientTest;
55
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
66
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
7+
using Microsoft.AspNetCore.E2ETesting;
78
using OpenQA.Selenium;
89
using OpenQA.Selenium.Support.UI;
910
using System;

src/Components/test/E2ETest/Tests/BindTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using BasicTestApp;
55
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
66
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
7+
using Microsoft.AspNetCore.E2ETesting;
78
using OpenQA.Selenium;
89
using OpenQA.Selenium.Support.UI;
910
using Xunit;

src/Components/test/E2ETest/Tests/CascadingValueTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using BasicTestApp;
55
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
66
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
7+
using Microsoft.AspNetCore.E2ETesting;
78
using OpenQA.Selenium;
89
using Xunit;
910
using Xunit.Abstractions;

src/Components/test/E2ETest/Tests/ComponentRenderingTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using BasicTestApp.HierarchicalImportsTest.Subdir;
1212
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
1313
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
14+
using Microsoft.AspNetCore.E2ETesting;
1415
using OpenQA.Selenium;
1516
using OpenQA.Selenium.Support.UI;
1617
using Xunit;

src/Components/test/E2ETest/Tests/EventBubblingTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using BasicTestApp;
55
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
66
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
7+
using Microsoft.AspNetCore.E2ETesting;
78
using OpenQA.Selenium;
89
using System;
910
using Xunit;

src/Components/test/E2ETest/Tests/EventCallbackTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using BasicTestApp;
55
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
66
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
7+
using Microsoft.AspNetCore.E2ETesting;
78
using OpenQA.Selenium;
89
using Xunit;
910
using Xunit.Abstractions;

src/Components/test/E2ETest/Tests/EventTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using BasicTestApp;
55
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
66
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
7+
using Microsoft.AspNetCore.E2ETesting;
78
using OpenQA.Selenium;
89
using OpenQA.Selenium.Interactions;
910
using Xunit;

src/Components/test/E2ETest/Tests/FormsTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using BasicTestApp.FormsTest;
66
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
77
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
8+
using Microsoft.AspNetCore.E2ETesting;
89
using OpenQA.Selenium;
910
using OpenQA.Selenium.Support.UI;
1011
using System;

src/Components/test/E2ETest/Tests/HostedInAspNetTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
55
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
6+
using Microsoft.AspNetCore.E2ETesting;
67
using OpenQA.Selenium;
78
using OpenQA.Selenium.Support.UI;
89
using System;

src/Components/test/E2ETest/Tests/HttpClientTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using BasicTestApp.HttpClientTest;
55
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
66
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
7+
using Microsoft.AspNetCore.E2ETesting;
78
using OpenQA.Selenium;
89
using OpenQA.Selenium.Support.UI;
910
using System;

src/Components/test/E2ETest/Tests/InteropTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using BasicTestApp;
44
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
55
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
6+
using Microsoft.AspNetCore.E2ETesting;
67
using OpenQA.Selenium;
78
using OpenQA.Selenium.Support.UI;
89
using Xunit;

src/Components/test/E2ETest/Tests/MonoSanityTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
55
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
6+
using Microsoft.AspNetCore.E2ETesting;
67
using OpenQA.Selenium;
78
using OpenQA.Selenium.Support.UI;
89
using System;

src/Components/test/E2ETest/Tests/PerformanceTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
55
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
6+
using Microsoft.AspNetCore.E2ETesting;
67
using OpenQA.Selenium;
78
using System;
89
using System.Linq;

src/Components/test/E2ETest/Tests/RoutingTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using BasicTestApp.RouterTest;
99
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
1010
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
11+
using Microsoft.AspNetCore.E2ETesting;
1112
using OpenQA.Selenium;
1213
using OpenQA.Selenium.Interactions;
1314
using Xunit;

src/Components/test/E2ETest/Tests/StandaloneAppTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
55
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
6+
using Microsoft.AspNetCore.E2ETesting;
67
using OpenQA.Selenium;
78
using OpenQA.Selenium.Support.UI;
89
using System;

0 commit comments

Comments
 (0)