Skip to content

Commit 6b1e763

Browse files
authored
Move to xunit.v3 (#13540)
* Move to xunit.v3 * Address API breaks in xunit.v3 * Progress on more xunit.v3 breaks * Address more breaks * Fix more errors * OutputType * Update Microsoft.VisualBasic.Forms.Tests.vbproj * Update BinaryFormatTests.csproj * Fix command-line * Fix * Small fix * Few more fixes * Fix * Fix * Update COM2PictureConverterTests.cs * Update COM2PictureConverter.cs * Fix build error * Fix test * Fix * Address review comment * For investigation * Isolate ToolStripTests by clearing LastKeyData * Set PlatformTarget as well * Revert "Set PlatformTarget as well" This reverts commit 8480526. * Fix apphost rid * Revert change that was done for debugging purposes * Update
1 parent 8fd522a commit 6b1e763

File tree

108 files changed

+388
-482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+388
-482
lines changed

Directory.Build.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
<ImplicitUsings>enable</ImplicitUsings>
1818
<GenerateDocumentationFile>True</GenerateDocumentationFile>
1919
<PublishWindowsPdb>false</PublishWindowsPdb>
20+
21+
<DefaultAppHostRuntimeIdentifier Condition="'$(TargetArchitecture)'!=''">win-$(TargetArchitecture)</DefaultAppHostRuntimeIdentifier>
2022
</PropertyGroup>
2123

2224
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
@@ -66,6 +68,10 @@
6668
<ExcludeByFile />
6769
</PropertyGroup>
6870

71+
<PropertyGroup>
72+
<TestRunnerName>XUnitV3</TestRunnerName>
73+
</PropertyGroup>
74+
6975
<!-- workaround for package downgrade in Microsoft.NetCore.Platforms -->
7076
<PropertyGroup>
7177
<DisableImplicitNETCorePlatformsReference>true</DisableImplicitNETCorePlatformsReference>

Directory.Packages.props

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
<PackageVersion Include="AwesomeAssertions" Version="$(AwesomeAssertionsVersion)" />
3434
<PackageVersion Include="Moq" Version="$(MoqPackageVersion)" />
3535
<PackageVersion Include="Microsoft.DotNet.RemoteExecutor" Version="$(MicrosoftDotNetRemoteExecutorVersion)" />
36-
<PackageVersion Include="Microsoft.DotNet.XUnitExtensions" Version="$(MicrosoftDotNetXUnitExtensionsPackageVersion)" />
36+
<PackageVersion Include="Microsoft.DotNet.XUnitV3Extensions" Version="$(MicrosoftDotNetXUnitV3ExtensionsPackageVersion)" />
3737
<PackageVersion Include="Microsoft.VisualStudio.Threading" Version="$(MicrosoftVisualStudioThreadingVersion)" />
38-
<PackageVersion Include="Verify.Xunit" Version="$(VerifyXunitVersion)" />
39-
<PackageVersion Include="xunit.assert" Version="$(XUnitAssertVersion)" Condition="'$(IsTestProject)' != 'true'" />
38+
<PackageVersion Include="Verify.XunitV3" Version="$(VerifyXunitV3Version)" />
39+
<PackageVersion Include="xunit.v3.assert" Version="$(XUnitV3Version)" Condition="'$(IsTestProject)' != 'true'" />
4040
<PackageVersion Include="xunit.stafact" Version="$(XUnitStaFactPackageVersion)" />
4141

4242
<!-- Code coverage-->
@@ -50,10 +50,6 @@
5050
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="$(MicrosoftCodeAnalysisAnalyzersVersion)" />
5151
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="$(MicrosoftCodeAnalysisCommonPackageVersion)" />
5252
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpPackageVersion)" />
53-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="$(MicrosoftCodeAnalysisPackagesVersion)" />
54-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="$(MicrosoftCodeAnalysisPackagesVersion)" />
55-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing.XUnit" Version="$(MicrosoftCodeAnalysisPackagesVersion)" />
56-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit" Version="$(MicrosoftCodeAnalysisPackagesVersion)" />
5753
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing" Version="$(MicrosoftCodeAnalysisPackagesVersion)" />
5854
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="$(MicrosoftCodeAnalysisPackagesVersion)" />
5955
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing" Version="$(MicrosoftCodeAnalysisPackagesVersion)" />
@@ -66,10 +62,6 @@
6662
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="$(MicrosoftCodeAnalysisNetAnalyzersVersion)" />
6763
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="$(MicrosoftCodeAnalysisPublicApiAnalyzersVersion)" />
6864
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic" Version="$(MicrosoftCodeAnalysisCSharpPackageVersion)" />
69-
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Analyzer.Testing.XUnit" Version="$(MicrosoftCodeAnalysisPackagesVersion)" />
70-
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing.XUnit" Version="$(MicrosoftCodeAnalysisPackagesVersion)" />
71-
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.CodeRefactoring.Testing.XUnit" Version="$(MicrosoftCodeAnalysisPackagesVersion)" />
72-
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.SourceGenerators.Testing.XUnit" Version="$(MicrosoftCodeAnalysisPackagesVersion)" />
7365
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="$(MicrosoftCodeAnalysisVisualBasicWorkspacesVersion)" />
7466
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="$(MicrosoftCodeAnalysisCSharpPackageVersion)" />
7567
<PackageVersion Include="NuGet.Packaging" Version="$(NugetPackagingVersion)" />

eng/Test.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<!-- Making all tests run sequentially until we regroup tests. Tracked under issue https://github.com/dotnet/winforms/issues/8810. -->
44
<PropertyGroup>
55
<XUnitCoreSettingsFile>$(RepositoryEngineeringDir)xunit.runner.json</XUnitCoreSettingsFile>
6+
7+
<OutputType>Exe</OutputType>
68
</PropertyGroup>
79

810
<ItemGroup>

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
2+
<!--
33
Dependencies registered here by Name and Uri will be updated by Maestro via darc update-dependencies
44
They will be updated either in eng/Versions.props (most) or in global.json (for example: Microsoft.DotNet.Arcade.Sdk)
55
Note: if the Uri is a new place, you will need to add a subscription from that place to us in the appropriate channel
@@ -103,7 +103,7 @@ Note: if the Uri is a new place, you will need to add a subscription from that p
103103
<Uri>https://github.com/dotnet/dotnet</Uri>
104104
<Sha>25bec1af21db71468c5c2c3a588dd54d0e058e9d</Sha>
105105
</Dependency>
106-
<Dependency Name="Microsoft.DotNet.XUnitExtensions" Version="10.0.0-beta.25311.107">
106+
<Dependency Name="Microsoft.DotNet.XUnitV3Extensions" Version="10.0.0-beta.25311.107">
107107
<Uri>https://github.com/dotnet/dotnet</Uri>
108108
<Sha>25bec1af21db71468c5c2c3a588dd54d0e058e9d</Sha>
109109
</Dependency>

eng/Versions.props

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,15 @@
4848
<PropertyGroup>
4949
<MicrosoftDotNetGenFacadesPackageVersion>10.0.0-beta.25311.107</MicrosoftDotNetGenFacadesPackageVersion>
5050
<MicrosoftDotNetRemoteExecutorVersion>10.0.0-beta.25311.107</MicrosoftDotNetRemoteExecutorVersion>
51-
<MicrosoftDotNetXUnitExtensionsPackageVersion>10.0.0-beta.25311.107</MicrosoftDotNetXUnitExtensionsPackageVersion>
51+
<MicrosoftDotNetXUnitV3ExtensionsPackageVersion>10.0.0-beta.25311.107</MicrosoftDotNetXUnitV3ExtensionsPackageVersion>
5252
<MicrosoftNETTestSdkVersion>17.4.0-preview-20220707-01</MicrosoftNETTestSdkVersion>
5353
</PropertyGroup>
5454
<!-- Below have no corresponding entries in Versions.Details.XML because they are not updated via Maestro -->
5555
<!-- XUnit-related (not extensions) -->
5656
<PropertyGroup>
57-
<XUnitVersion>2.9.2</XUnitVersion>
58-
<XUnitAssertVersion>$(XUnitVersion)</XUnitAssertVersion>
59-
<XUnitRunnerConsoleVersion>$(XUnitVersion)</XUnitRunnerConsoleVersion>
60-
<XUnitRunnerVisualStudioVersion>2.8.1</XUnitRunnerVisualStudioVersion>
61-
<XUnitExtensibilityExecutionVersion>$(XUnitVersion)</XUnitExtensibilityExecutionVersion>
62-
<XUnitStaFactPackageVersion>1.2.46-alpha</XUnitStaFactPackageVersion>
57+
<XUnitV3Version>2.0.2</XUnitV3Version>
58+
<XUnitRunnerVisualStudioVersion>3.1.0</XUnitRunnerVisualStudioVersion>
59+
<XUnitStaFactPackageVersion>2.1.7</XUnitStaFactPackageVersion>
6360
</PropertyGroup>
6461
<!-- Test related -->
6562
<PropertyGroup>
@@ -71,7 +68,10 @@
7168
<SystemComponentModelTypeConverterTestDataVersion>10.0.0-beta.24568.1</SystemComponentModelTypeConverterTestDataVersion>
7269
<SystemDrawingCommonTestDataVersion>10.0.0-beta.24568.1</SystemDrawingCommonTestDataVersion>
7370
<SystemWindowsExtensionsTestDataVersion>10.0.0-beta.24568.1</SystemWindowsExtensionsTestDataVersion>
74-
<VerifyXunitVersion>25.0.1</VerifyXunitVersion>
71+
<VerifyXunitV3Version>30.1.0</VerifyXunitV3Version>
72+
73+
<!-- Temporary: Remove once https://github.com/dotnet/arcade/pull/15904 flows to the repo -->
74+
<XUnitV3Version>2.0.3</XUnitV3Version>
7575
</PropertyGroup>
7676
<!-- Code Coverage -->
7777
<PropertyGroup>

eng/pipelines/build-PR.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
$(_OfficialBuildIdArgs)
9191
$(_InternalRuntimeDownloadArgs)
9292
/p:Coverage=$(_Coverage)
93-
/p:TestRunnerAdditionalArguments='-notrait Category=IgnoreForCI -notrait Category=failing'
93+
/p:TestRunnerAdditionalArguments='--filter-not-trait Category=IgnoreForCI --filter-not-trait Category=failing'
9494
/bl:$(BUILD.SOURCESDIRECTORY)\artifacts\log\$(_BuildConfig)\Test-${{ parameters.targetArchitecture }}.binlog
9595
/m:1
9696
displayName: Run Unit Tests
@@ -107,7 +107,7 @@ jobs:
107107
$(_OfficialBuildIdArgs)
108108
$(_InternalRuntimeDownloadArgs)
109109
/p:Coverage=$(_Coverage)
110-
/p:TestRunnerAdditionalArguments='-notrait Category=IgnoreForCI -notrait Category=failing'
110+
/p:TestRunnerAdditionalArguments='--filter-not-trait Category=IgnoreForCI --filter-not-trait Category=failing'
111111
/bl:$(BUILD.SOURCESDIRECTORY)\artifacts\log\$(_BuildConfig)\IntegrationTest-${{ parameters.targetArchitecture }}.binlog
112112
/m:1
113113
env:

eng/pipelines/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
$(_OfficialBuildIdArgs)
9494
$(_InternalRuntimeDownloadArgs)
9595
/p:Coverage=$(_Coverage)
96-
/p:TestRunnerAdditionalArguments='-notrait Category=IgnoreForCI -notrait Category=failing'
96+
/p:TestRunnerAdditionalArguments='--filter-not-trait Category=IgnoreForCI --filter-not-trait Category=failing'
9797
/bl:$(BUILD.SOURCESDIRECTORY)\artifacts\log\$(_BuildConfig)\Test-${{ parameters.targetArchitecture }}.binlog
9898
/m:1
9999
displayName: Run Unit Tests
@@ -110,7 +110,7 @@ jobs:
110110
$(_OfficialBuildIdArgs)
111111
$(_InternalRuntimeDownloadArgs)
112112
/p:Coverage=$(_Coverage)
113-
/p:TestRunnerAdditionalArguments='-notrait Category=IgnoreForCI -notrait Category=failing'
113+
/p:TestRunnerAdditionalArguments='--filter-not-trait Category=IgnoreForCI --filter-not-trait Category=failing'
114114
/bl:$(BUILD.SOURCESDIRECTORY)\artifacts\log\$(_BuildConfig)\IntegrationTest-${{ parameters.targetArchitecture }}.binlog
115115
/m:1
116116
env:

src/Common/tests/TestUtilities/CommonTestHelper.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static TheoryData<Point> GetPointTheoryData(TestIncludeType includeType)
7878
TheoryData<Point> data = new();
7979
if (!includeType.HasFlag(TestIncludeType.NoPositives))
8080
{
81-
data.Add(default);
81+
data.Add(default(Point));
8282
data.Add(new Point(10));
8383
data.Add(new Point(1, 2));
8484
}
@@ -99,7 +99,7 @@ public static TheoryData<Size> GetSizeTheoryData(TestIncludeType includeType)
9999
TheoryData<Size> data = new();
100100
if (!includeType.HasFlag(TestIncludeType.NoPositives))
101101
{
102-
data.Add(default);
102+
data.Add(default(Size));
103103
data.Add(new Size(new Point(1, 1)));
104104
data.Add(new Size(1, 2));
105105
}
@@ -126,7 +126,10 @@ public static TheoryData<Size> GetSizeTheoryData(TestIncludeType includeType)
126126
public static TheoryData<EventArgs?> GetEventArgsTheoryData()
127127
=> new()
128128
{
129-
null,
129+
// Cast is important. This calls Add(TheoryDataRow<T>) method.
130+
// Without the cast, this will pass a null TheoryDataRow<EventArgs> to the method.
131+
// With the cast, implicit conversion from null EventArgs to TheoryDataRow<EventArgs> is used.
132+
(EventArgs?)null,
130133
new EventArgs()
131134
};
132135

src/Common/tests/TestUtilities/System.Private.Windows.Core.TestUtilities.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
<ItemGroup>
1414
<PackageReference Include="AwesomeAssertions" />
1515
<PackageReference Include="Moq" />
16-
<PackageReference Include="xunit.assert" />
16+
<PackageReference Include="xunit.v3.assert" />
1717
<PackageReference Include="xunit.stafact" />
1818
<PackageReference Include="Microsoft.DotNet.RemoteExecutor" />
19-
<PackageReference Include="Microsoft.DotNet.XUnitExtensions" />
19+
<PackageReference Include="Microsoft.DotNet.XUnitV3Extensions" />
2020
<PackageReference Include="System.Formats.Nrbf" />
2121
</ItemGroup>
2222

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Reflection;
4+
using Xunit.v3;
55

66
namespace Xunit;
77

@@ -11,29 +11,15 @@ namespace Xunit;
1111
/// We cannot inherit from <see cref="MemberDataAttribute"/> as it is sealed, so we have to reimplement
1212
/// ConvertDataItem inheriting from MemberDataAttributeBase.
1313
/// </summary>
14+
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
1415
public class CommonMemberDataAttribute : MemberDataAttributeBase
1516
{
1617
public CommonMemberDataAttribute(Type memberType, string memberName = "TheoryData")
17-
: this(memberType, memberName, null) { }
18+
: this(memberType, memberName, Array.Empty<object>()) { }
1819

19-
public CommonMemberDataAttribute(Type memberType, string memberName, params object[]? parameters)
20+
public CommonMemberDataAttribute(Type memberType, string memberName, params object?[] parameters)
2021
: base(memberName, parameters)
2122
{
2223
MemberType = memberType;
2324
}
24-
25-
protected override object[]? ConvertDataItem(MethodInfo testMethod, object? item)
26-
{
27-
if (item is null)
28-
{
29-
return null;
30-
}
31-
32-
if (item is not object[] array)
33-
{
34-
throw new ArgumentException($"Property {MemberName} on {MemberType ?? testMethod.DeclaringType} yielded an item that is not an object[], but {item.GetType().Name}");
35-
}
36-
37-
return array;
38-
}
3925
}

0 commit comments

Comments
 (0)