Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void AddTestFramework(
TestingFrameworkExtension extension = new();
testApplicationBuilder.AddTreeNodeFilterService(extension);
testApplicationBuilder.RegisterTestFramework(
_ => new TestFrameworkCapabilities(testNodesBuilder),
serviceProvider => new TestFrameworkCapabilities(testNodesBuilder, new MSTestEngineBannerCapability(serviceProvider.GetRequiredService<IPlatformInformation>())),
(capabilities, serviceProvider) =>
new TestFramework(testFrameworkConfiguration, testNodesBuilder, extension, serviceProvider.GetSystemClock(),
serviceProvider.GetTask(), serviceProvider.GetConfiguration(), capabilities));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under dual-license. See LICENSE.PLATFORMTOOLS.txt file in the project root for full license information.

using Microsoft.Testing.Platform.Capabilities.TestFramework;
using Microsoft.Testing.Platform.Services;

namespace Microsoft.Testing.Framework;

internal sealed class MSTestEngineBannerCapability : IBannerMessageOwnerCapability
{
private readonly IPlatformInformation _platformInformation;

public MSTestEngineBannerCapability(IPlatformInformation platformInformation) => _platformInformation = platformInformation;

public Task<string?> GetBannerMessageAsync()
{
StringBuilder bannerMessage = new();
bannerMessage.Append("MSTest.Engine v");
bannerMessage.Append(MSTestEngineRepositoryVersion.Version);

if (_platformInformation.BuildDate is { } buildDate)
{
bannerMessage.Append(" (UTC ");
bannerMessage.Append(buildDate.UtcDateTime.ToShortDateString());
bannerMessage.Append(')');
}

#if NETCOREAPP
if (RuntimeFeature.IsDynamicCodeCompiled)
#endif
{
bannerMessage.Append(" [");
#if NET6_0_OR_GREATER
bannerMessage.Append(RuntimeInformation.RuntimeIdentifier);
#else
bannerMessage.Append(RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant());
#endif
bannerMessage.Append(" - ");
bannerMessage.Append(RuntimeInformation.FrameworkDescription);
bannerMessage.Append(']');
}

return Task.FromResult<string?>(bannerMessage.ToString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ namespace Microsoft.Testing.Framework;
internal sealed class TestFrameworkCapabilities : ITestFrameworkCapabilities
{
private readonly ITestNodesBuilder[] _testNodesBuilders;
private readonly ITestFrameworkCapability _bannerMessageOwnerCapability;

public TestFrameworkCapabilities(ITestNodesBuilder[] testNodesBuilders)
=> _testNodesBuilders = testNodesBuilders;
public TestFrameworkCapabilities(ITestNodesBuilder[] testNodesBuilders, IBannerMessageOwnerCapability bannerMessageOwnerCapability)
{
_testNodesBuilders = testNodesBuilders;
_bannerMessageOwnerCapability = bannerMessageOwnerCapability;
}

public IReadOnlyCollection<ITestFrameworkCapability> Capabilities
=> new[] { new TestFrameworkCapabilitiesSet(_testNodesBuilders) };
=> new[] { new TestFrameworkCapabilitiesSet(_testNodesBuilders), _bannerMessageOwnerCapability };
}

internal sealed class TestFrameworkCapabilitiesSet :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ await DotnetCli.RunAsync(
var testHost = TestHost.LocateFrom(generator.TargetAssetPath, "NativeAotTests", TargetFrameworks.NetCurrent, RID, Verb.publish);

TestHostResult result = await testHost.ExecuteAsync();
result.AssertOutputContains($"MSTest.Engine v{MSTestEngineVersion}");
result.AssertExitCodeIs(0);
}, times: 15, every: TimeSpan.FromSeconds(5));
}
Expand Down