-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix "Found multiple properties of type 'Microsoft.Testing.Platform.Ex… (
- Loading branch information
1 parent
8060ce0
commit b15aefd
Showing
3 changed files
with
144 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
test/IntegrationTests/MSTest.Acceptance.IntegrationTests/OutputTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// 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.Testing.Platform.Acceptance.IntegrationTests; | ||
using Microsoft.Testing.Platform.Acceptance.IntegrationTests.Helpers; | ||
|
||
namespace MSTest.Acceptance.IntegrationTests; | ||
|
||
[TestGroup] | ||
public sealed class OutputTests : AcceptanceTestBase | ||
{ | ||
private readonly TestAssetFixture _testAssetFixture; | ||
|
||
public OutputTests(ITestExecutionContext testExecutionContext, TestAssetFixture testAssetFixture) | ||
: base(testExecutionContext) => _testAssetFixture = testAssetFixture; | ||
|
||
[ArgumentsProvider(nameof(TargetFrameworks.All), typeof(TargetFrameworks))] | ||
public async Task DetailedOutputIsAsExpected(string tfm) | ||
{ | ||
var testHost = TestHost.LocateFrom(_testAssetFixture.ProjectPath, TestAssetFixture.ProjectName, tfm); | ||
TestHostResult testHostResult = await testHost.ExecuteAsync("--output detailed"); | ||
|
||
// Assert | ||
testHostResult.AssertOutputContains("Assert.AreEqual failed. Expected:<1>. Actual:<2>."); | ||
testHostResult.AssertOutputContains(""" | ||
Standard output | ||
Console message | ||
TestContext Messages: | ||
TestContext message | ||
Error output | ||
"""); | ||
} | ||
|
||
[TestFixture(TestFixtureSharingStrategy.PerTestGroup)] | ||
public sealed class TestAssetFixture(AcceptanceFixture acceptanceFixture) : TestAssetFixtureBase(acceptanceFixture.NuGetGlobalPackagesFolder) | ||
{ | ||
public const string ProjectName = "TestOutput"; | ||
|
||
public string ProjectPath => GetAssetPath(ProjectName); | ||
|
||
public override IEnumerable<(string ID, string Name, string Code)> GetAssetsToGenerate() | ||
{ | ||
yield return (ProjectName, ProjectName, | ||
SourceCode | ||
.PatchTargetFrameworks(TargetFrameworks.All) | ||
.PatchCodeWithReplace("$MSTestVersion$", MSTestVersion)); | ||
} | ||
|
||
private const string SourceCode = """ | ||
#file TestOutput.csproj | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<EnableMSTestRunner>true</EnableMSTestRunner> | ||
<TargetFrameworks>$TargetFrameworks$</TargetFrameworks> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="MSTest.TestAdapter" Version="$MSTestVersion$" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="$MSTestVersion$" /> | ||
</ItemGroup> | ||
</Project> | ||
#file UnitTest1.cs | ||
using System; | ||
using System.Diagnostics; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
[TestClass] | ||
public class UnitTest1 | ||
{ | ||
public TestContext TestContext { get; set; } | ||
[TestMethod] | ||
public void TestMethod() | ||
{ | ||
Debug.WriteLine("Debug message"); | ||
Console.WriteLine("Console message"); | ||
TestContext.WriteLine("TestContext message"); | ||
Assert.AreEqual(1, 2); | ||
} | ||
} | ||
"""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters