Skip to content

Commit 887c2df

Browse files
committed
Adapt IsolatedTestHost to xunit.v3
1 parent fb63f88 commit 887c2df

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.1.0" />
3737
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.6.0" />
3838
<PackageVersion Include="System.ValueTuple" Version="4.6.1" />
39-
<PackageVersion Include="xunit.abstractions" Version="2.0.3" />
39+
<PackageVersion Include="xunit.v3.core.mtp-v2" Version="3.2.1" />
4040
<PackageVersion Include="Xunit.Combinatorial" Version="2.0.24" />
4141
<PackageVersion Include="Xunit.StaFact" Version="3.0.13" />
4242
</ItemGroup>

test/IsolatedTestHost/IsolatedTestHost.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFrameworks>net472</TargetFrameworks>
6+
<IsTestProject>false</IsTestProject>
67
</PropertyGroup>
78

89
<ItemGroup>
9-
<PackageReference Include="xunit.abstractions" />
10+
<PackageReference Include="xunit.v3.core.mtp-v2" ExcludeAssets="buildTransitive" />
1011
</ItemGroup>
1112

1213
</Project>

test/IsolatedTestHost/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ private static ExitCode MyMain(string assemblyFile, string testClassName, string
5252
}
5353

5454
bool fact = testMethod.GetCustomAttributesData().Any(a => a.AttributeType.Name == "FactAttribute");
55-
bool skippableFact = testMethod.GetCustomAttributesData().Any(a => a.AttributeType.Name == "SkippableFactAttribute");
56-
if (fact || skippableFact)
55+
if (fact)
5756
{
5857
return ExecuteTest(testClass, testMethod);
5958
}
Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
using System;
5-
using Xunit.Abstractions;
4+
using System.Globalization;
5+
using System.Text;
6+
using Xunit;
67

78
namespace IsolatedTestHost;
89

910
internal class TestOutputHelper : ITestOutputHelper
1011
{
11-
public void WriteLine(string message)
12-
{
13-
Console.WriteLine(message);
14-
}
15-
16-
public void WriteLine(string format, params object[] args)
17-
{
18-
Console.WriteLine(format, args);
19-
}
12+
private readonly StringBuilder builder = new();
13+
14+
public string Output => this.builder.ToString();
15+
16+
public void Write(string message) => this.builder.Append(message);
17+
18+
public void Write(string format, params object[] args) => this.builder.AppendFormat(format, args);
19+
20+
public void WriteLine(string message) => this.builder.AppendLine(message);
21+
22+
public void WriteLine(string format, params object[] args) => this.builder.AppendLine(string.Format(CultureInfo.CurrentCulture, format, args));
2023
}

0 commit comments

Comments
 (0)