Skip to content

Commit 0c99e5f

Browse files
authored
Combining or Fixing Test Collections (#3472)
* use same collection for tests using token acquirer factory * use same collection for tests using token acquirer factory * fix UI test collection * remove file-scoped namespace changes for clarity * fixing spacing * formatting changes
1 parent 78d0087 commit 0c99e5f

12 files changed

+34
-49
lines changed

tests/E2E Tests/AgentApplications/AgentApplicationsTests.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
<ItemGroup>
1717
<PackageReference Include="coverlet.collector" Version="6.0.0" />
1818
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
19-
<PackageReference Include="xunit" Version="2.5.3" />
20-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
2119
</ItemGroup>
2220

2321
<ItemGroup>
@@ -27,6 +25,7 @@
2725
<ProjectReference Include="..\..\..\src\Microsoft.Identity.Web.GraphServiceClient\Microsoft.Identity.Web.GraphServiceClient.csproj" />
2826
<ProjectReference Include="..\..\..\src\Microsoft.Identity.Web.OidcFIC\Microsoft.Identity.Web.OidcFIC.csproj" />
2927
<ProjectReference Include="..\..\..\src\Microsoft.Identity.Web.TokenAcquisition\Microsoft.Identity.Web.TokenAcquisition.csproj" />
28+
<ProjectReference Include="..\..\Microsoft.Identity.Web.Test.Common\Microsoft.Identity.Web.Test.Common.csproj" />
3029
</ItemGroup>
3130

3231
<ItemGroup>

tests/E2E Tests/AgentApplications/GetFicAsyncTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
using Microsoft.Extensions.DependencyInjection;
77
using Microsoft.Identity.Abstractions;
88
using Microsoft.Identity.Web;
9+
using Microsoft.Identity.Web.Test.Common;
910

1011
namespace AgentApplicationsTests
1112
{
13+
[Collection(nameof(TokenAcquirerFactorySingletonProtection))]
1214
public class GetFicAsyncTests
1315
{
1416
[Fact]

tests/E2E Tests/WebAppUiTests/B2CWebAppCallsWebApiLocally.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace WebAppUiTests
1818
#if !FROM_GITHUB_ACTION
1919
{
2020
// since these tests change environment variables we'd prefer it not run at the same time as other tests
21-
[CollectionDefinition(nameof(UiTestNoParallelization), DisableParallelization = true)]
21+
[Collection(nameof(UiTestNoParallelization))]
2222
public class B2CWebAppCallsWebApiLocally : IClassFixture<InstallPlaywrightBrowserFixture>
2323
{
2424
private const string KeyvaultEmailName = "IdWeb-B2C-user";
@@ -69,7 +69,7 @@ public async Task Susi_B2C_LocalAccount_TodoAppFunctionsCorrectlyAsync()
6969
IBrowserContext context = await browser.NewContextAsync(new BrowserNewContextOptions { IgnoreHTTPSErrors = true });
7070
await context.Tracing.StartAsync(new() { Screenshots = true, Snapshots = true, Sources = true });
7171

72-
Process? serviceProcess= null;
72+
Process? serviceProcess = null;
7373
Process? clientProcess = null;
7474

7575
try

tests/E2E Tests/WebAppUiTests/TestingWebAppLocally.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace WebAppUiTests;
1818
#if !FROM_GITHUB_ACTION && !AZURE_DEVOPS_BUILD
1919

2020
// Since this test affects Kestrel environment variables it can cause a race condition when run in parallel with other UI tests.
21-
[CollectionDefinition(nameof(UiTestNoParallelization), DisableParallelization = true)]
21+
[Collection(nameof(UiTestNoParallelization))]
2222
public class TestingWebAppLocally : IClassFixture<InstallPlaywrightBrowserFixture>
2323
{
2424
private const string UrlString = "https://localhost:5001/MicrosoftIdentity/Account/signin";

tests/E2E Tests/WebAppUiTests/UiTestHelpers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ internal static bool StartAndVerifyProcessesAreRunning(List<ProcessStartOptions>
360360
{
361361
if (!UiTestHelpers.ProcessesAreAlive(processes.Values.ToList()))
362362
{
363-
RestartProcesses(processes, processDataEntries , output);
363+
RestartProcesses(processes, processDataEntries, output);
364364
}
365365
}
366366

@@ -384,7 +384,7 @@ static void RestartProcesses(Dictionary<string, Process> processes, List<Process
384384
processDataEntry.TestAssemblyLocation,
385385
processDataEntry.AppLocation,
386386
processDataEntry.ExecutableName,
387-
output,
387+
output,
388388
processDataEntry.EnvironmentVariables);
389389
Thread.Sleep(5000);
390390

tests/E2E Tests/WebAppUiTests/WebAppCallsApiCallsGraphLocally.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace WebAppUiTests
1818
#if !FROM_GITHUB_ACTION
1919
{
2020
// since these tests change environment variables we'd prefer it not run at the same time as other tests
21-
[CollectionDefinition(nameof(UiTestNoParallelization), DisableParallelization = true)]
21+
[Collection(nameof(UiTestNoParallelization))]
2222
public class WebAppCallsApiCallsGraphLocally : IClassFixture<InstallPlaywrightBrowserFixture>
2323
{
2424
private const uint GrpcPort = 5001;
@@ -116,7 +116,7 @@ public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPasswordCreds
116116
_output.WriteLine("Starting web app sign-in flow using Todo List button after sign out.");
117117
await page.GetByRole(AriaRole.Link, new() { Name = "TodoList" }).ClickAsync();
118118
await UiTestHelpers.SuccessiveLogin_MicrosoftIdFlow_ValidEmailPasswordAsync(page, email, labResponse.User.GetOrFetchPassword(), _output);
119-
var todoLink = page.GetByRole(AriaRole.Link, new() { Name = "Create New" });
119+
var todoLink = page.GetByRole(AriaRole.Link, new() { Name = "Create New" });
120120
await Assertions.Expect(todoLink).ToBeVisibleAsync(_assertVisibleOptions);
121121
_output.WriteLine("Web app sign-in flow successful using Todo List button after sign out.");
122122

@@ -226,7 +226,7 @@ public async Task ChallengeUser_MicrosoftIdFlow_LocalApp_ValidEmailPasswordCreds
226226
foreach (var process in processes)
227227
{
228228
#pragma warning disable CA1305 // Specify IFormatProvider
229-
runningProcesses.AppendLine($"Is {process.Key} running: {UiTestHelpers.ProcessIsAlive(process.Value )}");
229+
runningProcesses.AppendLine($"Is {process.Key} running: {UiTestHelpers.ProcessIsAlive(process.Value)}");
230230
#pragma warning restore CA1305 // Specify IFormatProvider
231231
}
232232
Assert.Fail(TC.WebAppCrashedString + " " + runningProcesses.ToString());

tests/E2E Tests/WebAppUiTests/WebAppIntegrationTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
using Xunit;
1111

1212
namespace WebAppUiTests
13-
{
1413
#if !FROM_GITHUB_ACTION
14+
{
1515

16+
[Collection(nameof(UiTestNoParallelization))]
1617
public class WebAppIntegrationTests
1718
{
1819
const string UrlString = "https://webapptestmsidweb.azurewebsites.net/MicrosoftIdentity/Account/signin";
@@ -47,6 +48,6 @@ public async Task ChallengeUser_MicrosoftIdentityFlow_RemoteApp_ValidEmailPasswo
4748
}
4849

4950
}
50-
#endif //FROM_GITHUB_ACTION
5151
}
5252
}
53+
#endif //FROM_GITHUB_ACTION

tests/Microsoft.Identity.Web.Test/FmiTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
using Microsoft.Extensions.DependencyInjection;
88
using Microsoft.Identity.Abstractions;
99
using Microsoft.Identity.Client;
10+
using Microsoft.Identity.Web.Test.Common;
1011
using Microsoft.Identity.Web.Test.Common.Mocks;
1112
using Microsoft.Identity.Web.TestOnly;
1213
using Xunit;
1314

1415
namespace Microsoft.Identity.Web.Test
1516
{
16-
[Collection("Run tests - serial")]
17+
[Collection(nameof(TokenAcquirerFactorySingletonProtection))]
1718
public class FmiTests
1819
{
1920
[Fact]
@@ -52,12 +53,12 @@ private TokenAcquirerFactory InitTokenAcquirerFactoryForFmi()
5253
options.ClientId = "urn:microsoft:identity:fmi";
5354
options.ExtraQueryParameters = new Dictionary<string, string>
5455
{
55-
{ "dc", "ESTS-PUB-SCUS-LZ1-FD000-TEST1" }
56+
{ "dc", "ESTS-PUB-SCUS-LZ1-FD000-TEST1" }
5657
};
5758
options.ClientCredentials = [ new CredentialDescription() {
5859
SourceType = CredentialSource.ClientSecret,
5960
ClientSecret = "someSecret"
60-
}];
61+
}];
6162
});
6263

6364
// Add MockedHttpClientFactory

tests/Microsoft.Identity.Web.Test/ManagedIdentityCaeTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.Identity.Web.TestOnly;
1010
using Xunit;
1111
using Microsoft.Identity.Web.Test;
12+
using Microsoft.Identity.Web.Test.Common;
1213
using NSubstitute;
1314
using System.Collections.Generic;
1415
using System.Net.Http;
@@ -20,7 +21,7 @@
2021

2122
namespace Microsoft.Identity.Web.Tests.Certificateless
2223
{
23-
[Collection("Run tests - serial")]
24+
[Collection(nameof(TokenAcquirerFactorySingletonProtection))]
2425
public class ManagedIdentityTests
2526
{
2627
private const string Scope = "https://management.azure.com/.default";

tests/Microsoft.Identity.Web.Test/ServiceCollectionExtensionsTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
using Microsoft.Extensions.Options;
1010
using Microsoft.Identity.Abstractions;
1111
using Microsoft.Identity.Client;
12+
using Microsoft.Identity.Web.Test.Common;
1213
using Xunit;
1314

1415
namespace Microsoft.Identity.Web.Test
1516
{
17+
[Collection(nameof(TokenAcquirerFactorySingletonProtection))]
1618
public class ServiceCollectionExtensionsTests
1719
{
1820
[Fact]

0 commit comments

Comments
 (0)