Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
86d4207
Migrate Microsoft.DotNet.HotReload.Watch.Aspire.Tests to MSTest.Sdk o…
Evangelink Jun 11, 2026
52eade3
Bump MSTest.Sdk to 4.3.0-preview.26311.10 + apply skill review fixes
Evangelink Jun 11, 2026
75a20cf
Address review: use Assert.IsExactInstanceOfType<T> for xUnit IsType …
Evangelink Jun 11, 2026
27da8c4
Remove redundant Using of Microsoft.VisualStudio.TestTools.UnitTesting
Jun 11, 2026
7a551eb
Replace AssertEx.SequenceEqual with Assert.AreSequenceEqual
Jun 11, 2026
cb50989
Move FluentAssertions Using + AwesomeAssertions PackageReference to t…
BagOfMandMs Jun 12, 2026
ead0658
Restore Watch.Aspire ProjectReference in dotnet-watch.Tests.csproj
Evangelink Jun 12, 2026
fe718be
Add shared Microsoft.DotNet.Test.MSTest.Utilities project
Evangelink Jun 12, 2026
d8d00b4
Migrate Microsoft.NET.Build.Containers.UnitTests to MSTest.Sdk
Jun 11, 2026
ae897e7
Decouple IntegrationTests from MSTest UnitTests project
Evangelink Jun 12, 2026
77af185
Use built-in $(UsingMSTestSdk) property instead of custom $(UseMSTest…
Evangelink Jun 12, 2026
b5ef128
Use ctor injection of TestContext to make fields readonly
Copilot Jun 12, 2026
1c3c44a
Use shared Microsoft.DotNet.Test.MSTest.Utilities for logger helpers
Evangelink Jun 12, 2026
1ef3028
Deploy Aspire launcher runtime closure for integration tests
Evangelink Jun 16, 2026
55440b9
Merge branch 'main' into evangelink/mstest-mtp-containers-unit-tests
Evangelink Jun 16, 2026
7cb2275
Fix MSTest analyzer violations (MSTEST0037/0049/0023)
Evangelink Jun 16, 2026
d8f93a3
Fix MSTest analyzer violations breaking main (Authoring.Tasks.Integra…
Evangelink Jun 16, 2026
a7165cf
Fix MSTest analyzer violations in Aspire.Tests (MSTEST0037 HasCount)
Evangelink Jun 17, 2026
c183546
Rename misleading test param isECR -> expectedIsGoogleArtifactRegistry
Evangelink Jun 17, 2026
1d09c44
Fix Helix failure: mark AuthHandshakeMessageHandlerTests [DoNotParall…
Evangelink Jun 17, 2026
e41d5a3
Reuse a single LoggerFactory in TestLoggerFactory
Evangelink Jun 17, 2026
68b5a61
Merge remote-tracking branch 'origin/main' into evangelink/mstest-mtp…
Evangelink Jun 18, 2026
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
36 changes: 9 additions & 27 deletions test/Microsoft.DotNet.Test.MSTest.Utilities/TestLoggerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,17 @@ namespace Microsoft.DotNet.Test.MSTest.Utilities;
/// </summary>
public sealed class TestLoggerFactory : ILoggerFactory
{
private readonly List<ILoggerProvider> _loggerProviders = new();
private readonly List<ILoggerFactory> _factories = new();
private readonly ILoggerFactory _loggerFactory;

public TestLoggerFactory(TestContext? testContext = null)
{
if (testContext is not null)
{
_loggerProviders.Add(new TestContextLoggerProvider(testContext));
}
}

public void Dispose()
{
while (_factories.Count > 0)
{
ILoggerFactory factory = _factories[0];
_factories.RemoveAt(0);
factory.Dispose();
}
}

public ILogger CreateLogger(string categoryName)
{
ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
_loggerFactory = LoggerFactory.Create(builder =>
{
builder.SetMinimumLevel(LogLevel.Trace);

foreach (ILoggerProvider loggerProvider in _loggerProviders)
if (testContext is not null)
{
builder.AddProvider(loggerProvider);
builder.AddProvider(new TestContextLoggerProvider(testContext));
}

builder.AddSimpleConsole(options =>
Expand All @@ -52,14 +33,15 @@ public ILogger CreateLogger(string categoryName)
options.IncludeScopes = true;
});
});

_factories.Add(loggerFactory);
return loggerFactory.CreateLogger(categoryName);
}

public void Dispose() => _loggerFactory.Dispose();

public ILogger CreateLogger(string categoryName) => _loggerFactory.CreateLogger(categoryName);

public ILogger CreateLogger() => CreateLogger("Test Host");

public void AddProvider(ILoggerProvider provider) => _loggerProviders.Add(provider);
public void AddProvider(ILoggerProvider provider) => _loggerFactory.AddProvider(provider);

private sealed class TestContextLoggerProvider(TestContext testContext) : ILoggerProvider
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.CompilerServices;
using FakeItEasy;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.NET.Build.Containers.IntegrationTests;
using Microsoft.NET.Build.Containers.UnitTests;
using NuGet.Protocol;
using Task = System.Threading.Tasks.Task;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.NET.Build.Containers.IntegrationTests;
using Microsoft.NET.Build.Containers.UnitTests;

namespace Microsoft.NET.Build.Containers.Tasks.IntegrationTests;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.CompilerServices;

namespace Microsoft.NET.Build.Containers.IntegrationTests;

// xUnit-flavoured Docker availability attributes for the IntegrationTests project.
//
// The companion Microsoft.NET.Build.Containers.UnitTests project was migrated to
// MSTest.Sdk and now exposes a `DockerUnavailableCondition : ConditionBaseAttribute`
// instead of the previous `DockerAvailableFactAttribute : FactAttribute` /
// `DockerAvailableTheoryAttribute : TheoryAttribute` pair. IntegrationTests is still
// an xUnit project, so it needs its own xUnit-compatible attributes.
//
// Implementation mirrors the previous UnitTests version: each invocation shells out to
// the docker CLI on first use and caches the result. Caching lives in DockerCliStatus
// (file-scoped class) so it does not pollute the rest of the namespace.

public class DockerAvailableTheoryAttribute : TheoryAttribute
{
public static string LocalRegistry => DockerCliStatus.LocalRegistry;

public DockerAvailableTheoryAttribute(
bool skipPodman = false,
[CallerFilePath] string? sourceFilePath = null,
[CallerLineNumber] int sourceLineNumber = 0)
: base(sourceFilePath, sourceLineNumber)
{
if (!DockerCliStatus.IsAvailable)
{
base.Skip = "Skipping test because Docker is not available on this host.";
}

if (skipPodman && DockerCliStatus.Command == DockerCli.PodmanCommand)
{
base.Skip = $"Skipping test with {DockerCliStatus.Command} cli.";
}
}
}

public class DockerAvailableFactAttribute : FactAttribute
{
public static string LocalRegistry => DockerCliStatus.LocalRegistry;

public DockerAvailableFactAttribute(
bool skipPodman = false,
bool checkContainerdStoreAvailability = false,
[CallerFilePath] string? sourceFilePath = null,
[CallerLineNumber] int sourceLineNumber = 0)
: base(sourceFilePath, sourceLineNumber)
{
if (!DockerCliStatus.IsAvailable)
{
base.Skip = "Skipping test because Docker is not available on this host.";
}
else if (checkContainerdStoreAvailability && DockerCliStatus.Command != DockerCli.PodmanCommand && !DockerCli.IsContainerdStoreEnabledForDocker())
{
base.Skip = "Skipping test because Docker daemon is not using containerd as the storage driver.";
}
else if (skipPodman && DockerCliStatus.Command == DockerCli.PodmanCommand)
{
base.Skip = $"Skipping test with {DockerCliStatus.Command} cli.";
}
}
}

// tiny optimization - since there are many instances of these attributes we should only
// query the daemon status once.
static file class DockerCliStatus
{
public static readonly bool IsAvailable;
public static readonly string? Command;
public static string LocalRegistry
=> Command == DockerCli.PodmanCommand ? KnownLocalRegistryTypes.Podman
: KnownLocalRegistryTypes.Docker;

static DockerCliStatus()
{
DockerCli cli = new(new Microsoft.NET.TestFramework.TestLoggerFactory());
IsAvailable = cli.IsAvailable();
Command = cli.GetCommand();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.NET.Build.Containers.UnitTests;
using ILogger = Microsoft.Extensions.Logging.ILogger;

namespace Microsoft.NET.Build.Containers.IntegrationTests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Formats.Tar;
Expand All @@ -9,7 +9,6 @@
using Microsoft.DotNet.Cli.Utils;
using Microsoft.NET.Build.Containers.LocalDaemons;
using Microsoft.NET.Build.Containers.Resources;
using Microsoft.NET.Build.Containers.UnitTests;
using ILogger = Microsoft.Extensions.Logging.ILogger;

namespace Microsoft.NET.Build.Containers.IntegrationTests;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Containers\Microsoft.NET.Build.Containers\Microsoft.NET.Build.Containers.csproj" />
<ProjectReference Include="..\Microsoft.NET.TestFramework\Microsoft.NET.TestFramework.csproj" />
<ProjectReference Include="..\Microsoft.NET.Build.Containers.UnitTests\Microsoft.NET.Build.Containers.UnitTests.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.NET.Build.Containers.IntegrationTests;
using Microsoft.NET.Build.Containers.UnitTests;
using static Microsoft.NET.Build.Containers.KnownStrings;
using static Microsoft.NET.Build.Containers.KnownStrings.Properties;

Expand Down
Loading
Loading