diff --git a/src/Adapter/MSTest.TestAdapter/Execution/TestExecutionManager.cs b/src/Adapter/MSTest.TestAdapter/Execution/TestExecutionManager.cs index e05a6e1b02..6393868783 100644 --- a/src/Adapter/MSTest.TestAdapter/Execution/TestExecutionManager.cs +++ b/src/Adapter/MSTest.TestAdapter/Execution/TestExecutionManager.cs @@ -28,6 +28,17 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution; #endif public class TestExecutionManager { + private sealed class RemotingMessageLogger : MarshalByRefObject, IMessageLogger + { + private readonly IMessageLogger _realMessageLogger; + + public RemotingMessageLogger(IMessageLogger messageLogger) + => _realMessageLogger = messageLogger; + + public void SendMessage(TestMessageLevel testMessageLevel, string message) + => _realMessageLogger.SendMessage(testMessageLevel, message); + } + /// /// Dictionary for test run parameters. /// @@ -451,7 +462,10 @@ private void ExecuteTestsWithTestRunner( // Run single test passing test context properties to it. IDictionary tcmProperties = TcmTestPropertiesProvider.GetTcmProperties(currentTest); Dictionary testContextProperties = GetTestContextProperties(tcmProperties, sourceLevelParameters); - UnitTestResult[] unitTestResult = testRunner.RunSingleTest(unitTestElement.TestMethod, testContextProperties); + + // testRunner could be in a different AppDomain. We cannot pass the testExecutionRecorder directly. + // Instead, we pass a proxy (remoting object) that is marshallable by ref. + UnitTestResult[] unitTestResult = testRunner.RunSingleTest(unitTestElement.TestMethod, testContextProperties, new RemotingMessageLogger(testExecutionRecorder)); PlatformServiceProvider.Instance.AdapterTraceLogger.LogInfo("Executed test {0}", unitTestElement.TestMethod.Name); diff --git a/src/Adapter/MSTest.TestAdapter/Execution/UnitTestRunner.cs b/src/Adapter/MSTest.TestAdapter/Execution/UnitTestRunner.cs index 6d6e854add..8f706dd7a8 100644 --- a/src/Adapter/MSTest.TestAdapter/Execution/UnitTestRunner.cs +++ b/src/Adapter/MSTest.TestAdapter/Execution/UnitTestRunner.cs @@ -11,6 +11,7 @@ using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel; using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices; using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; using UnitTestOutcome = Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.UnitTestOutcome; @@ -130,7 +131,7 @@ internal FixtureTestResult GetFixtureTestResult(TestMethod testMethod, string fi /// The test Method. /// The test context properties. /// The . - internal UnitTestResult[] RunSingleTest(TestMethod testMethod, IDictionary testContextProperties) + internal UnitTestResult[] RunSingleTest(TestMethod testMethod, IDictionary testContextProperties, IMessageLogger messageLogger) { Guard.NotNull(testMethod); @@ -138,7 +139,7 @@ internal UnitTestResult[] RunSingleTest(TestMethod testMethod, IDictionary(testContextProperties); - ITestContext testContext = PlatformServiceProvider.Instance.GetTestContext(testMethod, writer, properties); + ITestContext testContext = PlatformServiceProvider.Instance.GetTestContext(testMethod, writer, properties, messageLogger); testContext.SetOutcome(UTF.UnitTestOutcome.InProgress); // Get the testMethod diff --git a/src/Adapter/MSTest.TestAdapter/IPlatformServiceProvider.cs b/src/Adapter/MSTest.TestAdapter/IPlatformServiceProvider.cs index 8bf09bab56..db5390a5b9 100644 --- a/src/Adapter/MSTest.TestAdapter/IPlatformServiceProvider.cs +++ b/src/Adapter/MSTest.TestAdapter/IPlatformServiceProvider.cs @@ -3,6 +3,7 @@ using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface; using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter; @@ -121,5 +122,5 @@ ITestSourceHost CreateTestSourceHost( /// /// This was required for compatibility reasons since the TestContext object that the V1 adapter had for desktop is not .Net Core compliant. /// - ITestContext GetTestContext(ITestMethod testMethod, StringWriter writer, IDictionary properties); + ITestContext GetTestContext(ITestMethod testMethod, StringWriter writer, IDictionary properties, IMessageLogger messageLogger); } diff --git a/src/Adapter/MSTest.TestAdapter/PlatformServiceProvider.cs b/src/Adapter/MSTest.TestAdapter/PlatformServiceProvider.cs index 94bcdc3e8d..38d8259a8e 100644 --- a/src/Adapter/MSTest.TestAdapter/PlatformServiceProvider.cs +++ b/src/Adapter/MSTest.TestAdapter/PlatformServiceProvider.cs @@ -9,6 +9,7 @@ using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices; using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface; using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter; @@ -222,9 +223,9 @@ public ITestSourceHost CreateTestSourceHost( /// /// This was required for compatibility reasons since the TestContext object that the V1 adapter had for desktop is not .Net Core compliant. /// - public ITestContext GetTestContext(ITestMethod testMethod, StringWriter writer, IDictionary properties) + public ITestContext GetTestContext(ITestMethod testMethod, StringWriter writer, IDictionary properties, IMessageLogger messageLogger) { - var testContextImplementation = new TestContextImplementation(testMethod, writer, properties); + var testContextImplementation = new TestContextImplementation(testMethod, writer, properties, messageLogger); TestRunCancellationToken?.Register(CancelDelegate, testContextImplementation); return testContextImplementation; } diff --git a/src/Adapter/MSTestAdapter.PlatformServices/Interfaces/ITestContext.cs b/src/Adapter/MSTestAdapter.PlatformServices/Interfaces/ITestContext.cs index ade967e97a..c57763b367 100644 --- a/src/Adapter/MSTestAdapter.PlatformServices/Interfaces/ITestContext.cs +++ b/src/Adapter/MSTestAdapter.PlatformServices/Interfaces/ITestContext.cs @@ -85,4 +85,6 @@ public interface ITestContext /// /// The display name. void SetDisplayName(string? displayName); + + void DisplayMessage(MessageLevel messageLevel, string message); } diff --git a/src/Adapter/MSTestAdapter.PlatformServices/PublicAPI/PublicAPI.Unshipped.txt b/src/Adapter/MSTestAdapter.PlatformServices/PublicAPI/PublicAPI.Unshipped.txt index 7dc5c58110..6569d196f2 100644 --- a/src/Adapter/MSTestAdapter.PlatformServices/PublicAPI/PublicAPI.Unshipped.txt +++ b/src/Adapter/MSTestAdapter.PlatformServices/PublicAPI/PublicAPI.Unshipped.txt @@ -1 +1,3 @@ #nullable enable +Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.ITestContext.DisplayMessage(Microsoft.VisualStudio.TestTools.UnitTesting.MessageLevel messageLevel, string! message) -> void +override Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestContextImplementation.DisplayMessage(Microsoft.VisualStudio.TestTools.UnitTesting.MessageLevel messageLevel, string! message) -> void diff --git a/src/Adapter/MSTestAdapter.PlatformServices/Services/MessageLevel.cs b/src/Adapter/MSTestAdapter.PlatformServices/Services/MessageLevel.cs new file mode 100644 index 0000000000..455c39aaf8 --- /dev/null +++ b/src/Adapter/MSTestAdapter.PlatformServices/Services/MessageLevel.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices; + +internal static class MessageLevelExtensions +{ + public static TestMessageLevel ToTestMessageLevel(this MessageLevel messageLevel) + => messageLevel switch + { + MessageLevel.Informational => TestMessageLevel.Informational, + MessageLevel.Warning => TestMessageLevel.Warning, + MessageLevel.Error => TestMessageLevel.Error, + _ => throw new ArgumentOutOfRangeException(nameof(messageLevel)), + }; +} diff --git a/src/Adapter/MSTestAdapter.PlatformServices/Services/TestContextImplementation.cs b/src/Adapter/MSTestAdapter.PlatformServices/Services/TestContextImplementation.cs index 5685895cd2..010994cdc4 100644 --- a/src/Adapter/MSTestAdapter.PlatformServices/Services/TestContextImplementation.cs +++ b/src/Adapter/MSTestAdapter.PlatformServices/Services/TestContextImplementation.cs @@ -9,6 +9,7 @@ using System.Globalization; using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; using ITestMethod = Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.ObjectModel.ITestMethod; @@ -49,6 +50,7 @@ public class TestContextImplementation : TestContext, ITestContext /// Properties. /// private readonly Dictionary _properties; + private readonly IMessageLogger? _messageLogger; /// /// Specifies whether the writer is disposed or not. @@ -72,6 +74,17 @@ public class TestContextImplementation : TestContext, ITestContext private DataRow? _dataRow; #endif + /// + /// Initializes a new instance of the class. + /// + /// The test method. + /// The writer where diagnostic messages are written to. + /// Properties/configuration passed in. + /// The message logger to use. + internal TestContextImplementation(ITestMethod testMethod, StringWriter stringWriter, IDictionary properties, IMessageLogger messageLogger) + : this(testMethod, stringWriter, properties) + => _messageLogger = messageLogger; + /// /// Initializes a new instance of the class. /// @@ -357,5 +370,7 @@ public void ClearDiagnosticMessages() public void SetDisplayName(string? displayName) => TestDisplayName = displayName; + public override void DisplayMessage(MessageLevel messageLevel, string message) + => _messageLogger?.SendMessage(messageLevel.ToTestMessageLevel(), message); #endregion } diff --git a/src/TestFramework/TestFramework.Extensions/MessageLevel.cs b/src/TestFramework/TestFramework.Extensions/MessageLevel.cs new file mode 100644 index 0000000000..064b617131 --- /dev/null +++ b/src/TestFramework/TestFramework.Extensions/MessageLevel.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.VisualStudio.TestTools.UnitTesting; + +/// +/// Specifies the severity level of messages displayed using the API. +/// +public enum MessageLevel +{ + /// + /// The message will be displayed as informational, typically used for general updates or non-critical messages. + /// + Informational, + + /// + /// The message will be displayed as a warning, indicating a potential issue or something requiring attention. + /// + Warning, + + /// + /// The message will be displayed as an error, representing a significant issue or failure. + /// + Error, +} diff --git a/src/TestFramework/TestFramework.Extensions/PublicAPI/PublicAPI.Unshipped.txt b/src/TestFramework/TestFramework.Extensions/PublicAPI/PublicAPI.Unshipped.txt index 7dc5c58110..5b7e887699 100644 --- a/src/TestFramework/TestFramework.Extensions/PublicAPI/PublicAPI.Unshipped.txt +++ b/src/TestFramework/TestFramework.Extensions/PublicAPI/PublicAPI.Unshipped.txt @@ -1 +1,6 @@ #nullable enable +abstract Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.DisplayMessage(Microsoft.VisualStudio.TestTools.UnitTesting.MessageLevel messageLevel, string! message) -> void +Microsoft.VisualStudio.TestTools.UnitTesting.MessageLevel +Microsoft.VisualStudio.TestTools.UnitTesting.MessageLevel.Error = 2 -> Microsoft.VisualStudio.TestTools.UnitTesting.MessageLevel +Microsoft.VisualStudio.TestTools.UnitTesting.MessageLevel.Informational = 0 -> Microsoft.VisualStudio.TestTools.UnitTesting.MessageLevel +Microsoft.VisualStudio.TestTools.UnitTesting.MessageLevel.Warning = 1 -> Microsoft.VisualStudio.TestTools.UnitTesting.MessageLevel diff --git a/src/TestFramework/TestFramework.Extensions/TestContext.cs b/src/TestFramework/TestFramework.Extensions/TestContext.cs index 83082db374..1d559cccd2 100644 --- a/src/TestFramework/TestFramework.Extensions/TestContext.cs +++ b/src/TestFramework/TestFramework.Extensions/TestContext.cs @@ -201,6 +201,8 @@ public abstract class TestContext /// the arguments. public abstract void WriteLine(string format, params object?[] args); + public abstract void DisplayMessage(MessageLevel messageLevel, string message); + private T? GetProperty(string name) where T : class { diff --git a/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/TestContextImplementationTests.cs b/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/TestContextImplementationTests.cs index b2a1ec1e32..fdac028df8 100644 --- a/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/TestContextImplementationTests.cs +++ b/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/TestContextImplementationTests.cs @@ -7,6 +7,8 @@ #endif using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; @@ -389,4 +391,21 @@ public void GetResultFilesShouldReturnListOfAddedResultFiles() Verify(resultFiles.Contains("C:\\files\\myfile2.txt")); } #endif + + public void DisplayMessageShouldForwardToIMessageLogger() + { + var messageLoggerMock = new Mock(MockBehavior.Strict); + + messageLoggerMock + .Setup(l => l.SendMessage(It.IsAny(), It.IsAny())); + + _testContextImplementation = new TestContextImplementation(_testMethod.Object, new ThreadSafeStringWriter(null, "test"), _properties, messageLoggerMock.Object); + _testContextImplementation.DisplayMessage(MessageLevel.Informational, "InfoMessage"); + _testContextImplementation.DisplayMessage(MessageLevel.Warning, "WarningMessage"); + _testContextImplementation.DisplayMessage(MessageLevel.Error, "ErrorMessage"); + + messageLoggerMock.Verify(x => x.SendMessage(TestMessageLevel.Informational, "InfoMessage"), Times.Once); + messageLoggerMock.Verify(x => x.SendMessage(TestMessageLevel.Warning, "WarningMessage"), Times.Once); + messageLoggerMock.Verify(x => x.SendMessage(TestMessageLevel.Error, "ErrorMessage"), Times.Once); + } } diff --git a/test/UnitTests/MSTestAdapter.UnitTests/Execution/UnitTestRunnerTests.cs b/test/UnitTests/MSTestAdapter.UnitTests/Execution/UnitTestRunnerTests.cs index 186ecb58de..d5d08b00ee 100644 --- a/test/UnitTests/MSTestAdapter.UnitTests/Execution/UnitTestRunnerTests.cs +++ b/test/UnitTests/MSTestAdapter.UnitTests/Execution/UnitTestRunnerTests.cs @@ -85,12 +85,12 @@ public void ConstructorShouldPopulateSettings() #region RunSingleTest tests public void RunSingleTestShouldThrowIfTestMethodIsNull() => - VerifyThrows(() => _unitTestRunner.RunSingleTest(null, null)); + VerifyThrows(() => _unitTestRunner.RunSingleTest(null, null, null)); public void RunSingleTestShouldThrowIfTestRunParametersIsNull() { var testMethod = new TestMethod("M", "C", "A", isAsync: false); - VerifyThrows(() => _unitTestRunner.RunSingleTest(testMethod, null)); + VerifyThrows(() => _unitTestRunner.RunSingleTest(testMethod, null, null)); } public void RunSingleTestShouldReturnTestResultIndicateATestNotFoundIfTestMethodCannotBeFound() @@ -100,7 +100,7 @@ public void RunSingleTestShouldReturnTestResultIndicateATestNotFoundIfTestMethod _testablePlatformServiceProvider.MockFileOperations.Setup(fo => fo.LoadAssembly("A", It.IsAny())) .Returns(Assembly.GetExecutingAssembly()); - UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters); + UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters, null); Verify(results is not null); Verify(results.Length == 1); @@ -117,7 +117,7 @@ public void RunSingleTestShouldReturnTestResultIndicatingNotRunnableTestIfTestMe _testablePlatformServiceProvider.MockFileOperations.Setup(fo => fo.LoadAssembly("A", It.IsAny())) .Returns(Assembly.GetExecutingAssembly()); - UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters); + UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters, null); string expectedMessage = string.Format( CultureInfo.InvariantCulture, @@ -140,7 +140,7 @@ public void ExecuteShouldSkipTestAndFillInClassIgnoreMessageIfIgnoreAttributeIsP _testablePlatformServiceProvider.MockFileOperations.Setup(fo => fo.LoadAssembly("A", It.IsAny())) .Returns(Assembly.GetExecutingAssembly()); - UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters); + UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters, null); Verify(results is not null); Verify(results.Length == 1); @@ -157,7 +157,7 @@ public void ExecuteShouldSkipTestAndSkipFillingIgnoreMessageIfIgnoreAttributeIsP _testablePlatformServiceProvider.MockFileOperations.Setup(fo => fo.LoadAssembly("A", It.IsAny())) .Returns(Assembly.GetExecutingAssembly()); - UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters); + UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters, null); Verify(results is not null); Verify(results.Length == 1); @@ -174,7 +174,7 @@ public void ExecuteShouldSkipTestAndFillInMethodIgnoreMessageIfIgnoreAttributeIs _testablePlatformServiceProvider.MockFileOperations.Setup(fo => fo.LoadAssembly("A", It.IsAny())) .Returns(Assembly.GetExecutingAssembly()); - UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters); + UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters, null); Verify(results is not null); Verify(results.Length == 1); @@ -191,7 +191,7 @@ public void ExecuteShouldSkipTestAndSkipFillingIgnoreMessageIfIgnoreAttributeIsP _testablePlatformServiceProvider.MockFileOperations.Setup(fo => fo.LoadAssembly("A", It.IsAny())) .Returns(Assembly.GetExecutingAssembly()); - UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters); + UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters, null); Verify(results is not null); Verify(results.Length == 1); @@ -208,7 +208,7 @@ public void ExecuteShouldSkipTestAndFillInClassIgnoreMessageIfIgnoreAttributeIsP _testablePlatformServiceProvider.MockFileOperations.Setup(fo => fo.LoadAssembly("A", It.IsAny())) .Returns(Assembly.GetExecutingAssembly()); - UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters); + UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters, null); Verify(results is not null); Verify(results.Length == 1); @@ -225,7 +225,7 @@ public void ExecuteShouldSkipTestAndFillInMethodIgnoreMessageIfIgnoreAttributeIs _testablePlatformServiceProvider.MockFileOperations.Setup(fo => fo.LoadAssembly("A", It.IsAny())) .Returns(Assembly.GetExecutingAssembly()); - UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters); + UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters, null); Verify(results is not null); Verify(results.Length == 1); @@ -241,7 +241,7 @@ public void RunSingleTestShouldReturnTestResultIndicatingFailureIfThereIsAnyType _testablePlatformServiceProvider.MockFileOperations.Setup(fo => fo.LoadAssembly("A", It.IsAny())) .Returns(Assembly.GetExecutingAssembly()); - UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters); + UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters, null); string expectedMessage = string.Format( CultureInfo.InvariantCulture, @@ -264,7 +264,7 @@ public void RunSingleTestShouldReturnTestResultsForAPassingTestMethod() _testablePlatformServiceProvider.MockFileOperations.Setup(fo => fo.LoadAssembly("A", It.IsAny())) .Returns(Assembly.GetExecutingAssembly()); - UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters); + UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters, null); Verify(results is not null); Verify(results.Length == 1); @@ -282,7 +282,7 @@ public void RunSingleTestShouldSetTestsAsInProgressInTestContext() .Returns(Assembly.GetExecutingAssembly()); // Asserting in the test method execution flow itself. - UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters); + UnitTestResult[] results = _unitTestRunner.RunSingleTest(testMethod, _testRunParameters, null); Verify(results is not null); Verify(results.Length == 1); @@ -308,7 +308,7 @@ public void RunSingleTestShouldCallAssemblyInitializeAndClassInitializeMethodsIn DummyTestClassWithInitializeMethods.AssemblyInitializeMethodBody = () => validator <<= 2; DummyTestClassWithInitializeMethods.ClassInitializeMethodBody = () => validator >>= 2; - _unitTestRunner.RunSingleTest(testMethod, _testRunParameters); + _unitTestRunner.RunSingleTest(testMethod, _testRunParameters, null); Verify(validator == 1); } diff --git a/test/UnitTests/MSTestAdapter.UnitTests/PlatformServiceProviderTests.cs b/test/UnitTests/MSTestAdapter.UnitTests/PlatformServiceProviderTests.cs index 4aa2b30fce..7109a8a7bf 100644 --- a/test/UnitTests/MSTestAdapter.UnitTests/PlatformServiceProviderTests.cs +++ b/test/UnitTests/MSTestAdapter.UnitTests/PlatformServiceProviderTests.cs @@ -64,7 +64,7 @@ public void GetTestContextShouldReturnAValidTestContext() testMethod.Setup(tm => tm.Name).Returns("M"); // Act. - PlatformServices.Interface.ITestContext testContext = PlatformServiceProvider.Instance.GetTestContext(testMethod.Object, writer, properties); + PlatformServices.Interface.ITestContext testContext = PlatformServiceProvider.Instance.GetTestContext(testMethod.Object, writer, properties, null); // Assert. Verify(testContext.Context.FullyQualifiedTestClassName == "A.C.M"); diff --git a/test/UnitTests/MSTestAdapter.UnitTests/TestableImplementations/TestablePlatformServiceProvider.cs b/test/UnitTests/MSTestAdapter.UnitTests/TestableImplementations/TestablePlatformServiceProvider.cs index afec0277f4..96627190a9 100644 --- a/test/UnitTests/MSTestAdapter.UnitTests/TestableImplementations/TestablePlatformServiceProvider.cs +++ b/test/UnitTests/MSTestAdapter.UnitTests/TestableImplementations/TestablePlatformServiceProvider.cs @@ -7,6 +7,7 @@ using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices; using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface; using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; using Moq; @@ -125,7 +126,7 @@ public IReflectionOperations2 ReflectionOperations public TestRunCancellationToken TestRunCancellationToken { get; set; } - public ITestContext GetTestContext(ITestMethod testMethod, StringWriter writer, IDictionary properties) => new TestContextImplementation(testMethod, writer, properties); + public ITestContext GetTestContext(ITestMethod testMethod, StringWriter writer, IDictionary properties, IMessageLogger messageLogger) => new TestContextImplementation(testMethod, writer, properties, messageLogger); public ITestSourceHost CreateTestSourceHost(string source, TestPlatform.ObjectModel.Adapter.IRunSettings runSettings, TestPlatform.ObjectModel.Adapter.IFrameworkHandle frameworkHandle) => MockTestSourceHost.Object;