Skip to content

Commit 7bda1ab

Browse files
committed
Migrate to xunit v3
1 parent 06ee0a5 commit 7bda1ab

125 files changed

Lines changed: 1755 additions & 2081 deletions

File tree

Some content is hidden

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

Directory.Packages.props

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<SystemTextJsonVersion Condition="'$(SystemTextJsonVersion)' == ''">8.0.5</SystemTextJsonVersion>
1111
<SystemCommandLineVersion Condition="'$(SystemCommandLineVersion)' == ''">2.0.0-beta7.25374.102</SystemCommandLineVersion>
1212
<MSTestPackageVersion>3.4.3</MSTestPackageVersion>
13+
<xunitv3PackageVersion>3.2.2</xunitv3PackageVersion>
1314
</PropertyGroup>
1415

1516
<PropertyGroup>
@@ -73,7 +74,7 @@
7374
<PackageVersion Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.14.40177" />
7475
<PackageVersion Include="Microsoft.VisualStudio.Extensibility.Build" Version=" 17.14.40177" />
7576
<PackageVersion Include="Microsoft.VisualStudio.SDK" Version="18.0.2345-preview.1" />
76-
<PackageVersion Include="Microsoft.VisualStudio.Sdk.TestFramework.Xunit" Version="17.11.8" />
77+
<PackageVersion Include="Microsoft.VisualStudio.Sdk.TestFramework.Xunit.v3" Version="17.11.66" />
7778
<PackageVersion Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="3.4.2244" />
7879
<PackageVersion Include="Microsoft.VisualStudio.Shell.Styles" Version="18.0.2345-preview.1" />
7980
<PackageVersion Include="Microsoft.VisualStudio.TemplateWizardInterface" Version="17.10.40170" />
@@ -104,9 +105,11 @@
104105
-->
105106
<PackageVersion Include="System.Threading.Tasks.Dataflow" Version="4.9.0" />
106107
<PackageVersion Include="VsWebSite.Interop" Version="17.10.40173" />
107-
<PackageVersion Include="xunit" Version="2.9.0" />
108+
<PackageVersion Include="xunit.v3" Version="$(xunitv3PackageVersion)" />
109+
<PackageVersion Include="xunit.v3.assert" Version="$(xunitv3PackageVersion)" />
110+
<PackageVersion Include="xunit.v3.extensibility.core" Version="$(xunitv3PackageVersion)" />
108111
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
109-
<PackageVersion Include="Xunit.StaFact" Version="1.1.11" />
112+
<PackageVersion Include="Xunit.StaFact" Version="3.0.13" />
110113
</ItemGroup>
111114

112115
<!--

build/test.targets

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
<!-- Shared test project template -->
55

66
<PropertyGroup>
7-
<NoWarn>$(NoWarn);CS1701;xUnit1012;xUnit1014;xUnit2000;xUnit2009;xUnit2013</NoWarn>
7+
<OutputType>Exe</OutputType>
8+
<NoWarn>$(NoWarn);CS1701;xUnit1012;xUnit1014;xUnit1051;xUnit2000;xUnit2009;xUnit2013;xUnit2031</NoWarn>
89
<WarningsAsErrors>$(WarningsAsErrors);xUnit2024</WarningsAsErrors>
910
</PropertyGroup>
1011

1112
<ItemGroup>
1213
<PackageReference Include="Microsoft.NET.Test.Sdk" />
1314
<PackageReference Include="xunit.runner.visualstudio" />
14-
<PackageReference Include="xunit" />
15+
<PackageReference Include="xunit.v3" />
1516
<PackageReference Include="Moq" />
1617
<PackageReference Include="AwesomeAssertions" />
1718
</ItemGroup>

test/NuGet.Clients.FuncTests/NuGet.CommandLine.FuncTest/CommandRunnerTest.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using NuGet.Common;
1313
using NuGet.Test.Utility;
1414
using Xunit;
15-
using Xunit.Abstractions;
1615

1716
namespace NuGet.CommandLine.FuncTest
1817
{
@@ -73,7 +72,7 @@ public void Run_CanGetExitCode()
7372
fileName,
7473
arguments: args,
7574
timeOutInMilliseconds: 10000,
76-
testOutputHelper: _testOutputHelper);
75+
logLine: _testOutputHelper.WriteLine);
7776

7877
result.ExitCode.Should().Be(16);
7978
}
@@ -103,7 +102,7 @@ public void Run_CanWriteToStandardInput()
103102
writer.WriteLine("echo Hello & exit 0");
104103
},
105104
timeOutInMilliseconds: 5000,
106-
testOutputHelper: _testOutputHelper);
105+
logLine: _testOutputHelper.WriteLine);
107106

108107
result.Output.Should().Contain("Hello");
109108
}
@@ -154,7 +153,7 @@ public void Run_DoesNotHangWhenReadingLargeStdout(int outputSizeInKilobytes)
154153
fileName,
155154
Directory.GetCurrentDirectory(),
156155
args,
157-
testOutputHelper: _testOutputHelper);
156+
logLine: _testOutputHelper.WriteLine);
158157

159158
// Assert
160159
Assert.Equal(0, result.ExitCode);
@@ -193,7 +192,7 @@ public void Run_TimesOut()
193192

194193
Stopwatch stopwatch = Stopwatch.StartNew();
195194

196-
new Action(() => CommandRunner.Run(fileName, arguments: args, timeOutInMilliseconds: 1000, testOutputHelper: _testOutputHelper, timeoutRetryCount: 0))
195+
new Action(() => CommandRunner.Run(fileName, arguments: args, timeOutInMilliseconds: 1000, logLine: _testOutputHelper.WriteLine, timeoutRetryCount: 0))
197196
.Should().Throw<TimeoutException>();
198197

199198
stopwatch.Stop();
@@ -224,7 +223,7 @@ private void VerifyWithCommandRunner()
224223
fileName,
225224
Directory.GetCurrentDirectory(),
226225
args,
227-
testOutputHelper: _testOutputHelper);
226+
logLine: _testOutputHelper.WriteLine);
228227

229228
// Assert
230229
Assert.Equal(0, result.ExitCode);

test/NuGet.Clients.FuncTests/NuGet.CommandLine.FuncTest/Commands/InstallCommandTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
using NuGet.Test.Utility;
1414
using Test.Utility.Signing;
1515
using Xunit;
16-
using Xunit.Abstractions;
1716

1817
namespace NuGet.CommandLine.FuncTest.Commands
1918
{
@@ -249,7 +248,7 @@ public CommandRunnerResult RunInstall(string nugetExe, SimpleTestPathContext pat
249248
pathContext.WorkingDirectory,
250249
string.Join(" ", args),
251250
environmentVariables: envVars,
252-
testOutputHelper: _testOutputHelper);
251+
logLine: _testOutputHelper.WriteLine);
253252

254253
// Assert
255254
Assert.True(expectedExitCode == r.ExitCode, r.AllOutput);

test/NuGet.Clients.FuncTests/NuGet.CommandLine.FuncTest/Commands/PushCommandTest.cs

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
using NuGet.Test.Utility;
1515
using Test.Utility;
1616
using Xunit;
17-
using Xunit.Abstractions;
1817

1918
namespace NuGet.CommandLine.FuncTest.Commands
2019
{
@@ -73,7 +72,7 @@ public void PushCommand_AllowsTimeoutToBeSpecifiedHigherThan100Seconds()
7372
pathContext.WorkingDirectory,
7473
$"push {sourcePath} -Source {server.Uri}push -Timeout 110",
7574
timeOutInMilliseconds: 120 * 1000,
76-
testOutputHelper: _testOutputHelper); // 120 seconds
75+
logLine: _testOutputHelper.WriteLine); // 120 seconds
7776
}
7877
// Assert
7978
Assert.True(result.Success, $"{result.Output} {result.Errors}");
@@ -117,7 +116,7 @@ public void PushCommand_AllowsTimeoutToBeSpecifiedLowerThan100Seconds()
117116
pathContext.WorkingDirectory,
118117
$"push {sourcePath} -Source {server.Uri}push -Timeout 1",
119118
timeOutInMilliseconds: 20 * 1000,
120-
testOutputHelper: _testOutputHelper); // 20 seconds
119+
logLine: _testOutputHelper.WriteLine); // 20 seconds
121120
}
122121

123122
// Assert
@@ -158,22 +157,22 @@ public void PushCommand_Server_SkipDuplicate_NotSpecified_PushHalts()
158157
pathContext.WorkingDirectory,
159158
$"push {sourcePath} -Source {server.Uri}push -Timeout 110",
160159
timeOutInMilliseconds: 120 * 1000,
161-
testOutputHelper: _testOutputHelper); // 120 seconds
160+
logLine: _testOutputHelper.WriteLine); // 120 seconds
162161

163162
//Run again so that it will be a duplicate push.
164163
result2 = CommandRunner.Run(
165164
nuget,
166165
pathContext.WorkingDirectory,
167166
$"push {sourcePath} -Source {server.Uri}push -Timeout 110",
168167
timeOutInMilliseconds: 120 * 1000,
169-
testOutputHelper: _testOutputHelper); // 120 seconds
168+
logLine: _testOutputHelper.WriteLine); // 120 seconds
170169

171170
result3 = CommandRunner.Run(
172171
nuget,
173172
pathContext.WorkingDirectory,
174173
$"push {sourcePath2} -Source {server.Uri}push -Timeout 110",
175174
timeOutInMilliseconds: 120 * 1000,
176-
testOutputHelper: _testOutputHelper); // 120 seconds
175+
logLine: _testOutputHelper.WriteLine); // 120 seconds
177176
}
178177

179178
// Assert
@@ -224,23 +223,23 @@ public void PushCommand_Server_SkipDuplicate_IsSpecified_PushProceeds()
224223
pathContext.WorkingDirectory,
225224
$"push {sourcePath} -Source {server.Uri}push -Timeout 110 -SkipDuplicate",
226225
timeOutInMilliseconds: 120 * 1000,
227-
testOutputHelper: _testOutputHelper); // 120 seconds
226+
logLine: _testOutputHelper.WriteLine); // 120 seconds
228227

229228
//Run again so that it will be a duplicate push but use the option to skip duplicate packages.
230229
result2 = CommandRunner.Run(
231230
nuget,
232231
pathContext.WorkingDirectory,
233232
$"push {sourcePath} -Source {server.Uri}push -Timeout 110 -SkipDuplicate",
234233
timeOutInMilliseconds: 120 * 1000,
235-
testOutputHelper: _testOutputHelper); // 120 seconds
234+
logLine: _testOutputHelper.WriteLine); // 120 seconds
236235

237236
//Third run with a different package.
238237
result3 = CommandRunner.Run(
239238
nuget,
240239
pathContext.WorkingDirectory,
241240
$"push {sourcePath2} -Source {server.Uri}push -Timeout 110 -SkipDuplicate",
242241
timeOutInMilliseconds: 120 * 1000,
243-
testOutputHelper: _testOutputHelper); // 120 seconds
242+
logLine: _testOutputHelper.WriteLine); // 120 seconds
244243
}
245244

246245
// Assert
@@ -287,7 +286,7 @@ public void PushCommand_Server_Snupkg_ByFilename_DoesNotExist_FileNotFoundError(
287286
pathContext.WorkingDirectory,
288287
$"push {snupkgToPush} -Source {sourceName} -Timeout 110",
289288
timeOutInMilliseconds: 120000,
290-
testOutputHelper: _testOutputHelper); // 120 seconds
289+
logLine: _testOutputHelper.WriteLine); // 120 seconds
291290
}
292291

293292
// Assert
@@ -324,7 +323,7 @@ public void PushCommand_Server_Snupkg_ByWildcard_FindsNothing_FileNotFoundError(
324323
pathContext.WorkingDirectory,
325324
$"push {snupkgToPush} -Source {sourceName} -Timeout 110",
326325
timeOutInMilliseconds: 120000,
327-
testOutputHelper: _testOutputHelper); // 120 seconds
326+
logLine: _testOutputHelper.WriteLine); // 120 seconds
328327
}
329328

330329
//Assert
@@ -359,7 +358,7 @@ public void PushCommand_Server_Nupkg_ByFilename_FindsNothing_FileNotFoundError()
359358
pathContext.WorkingDirectory,
360359
$"push {nupkgToPush} -Source {sourceName} -Timeout 110",
361360
timeOutInMilliseconds: 120000,
362-
testOutputHelper: _testOutputHelper); // 120 seconds
361+
logLine: _testOutputHelper.WriteLine); // 120 seconds
363362
}
364363

365364
//Assert
@@ -394,7 +393,7 @@ public void PushCommand_Server_Nupkg_ByWildcard_FindsNothing_FileNotFoundError()
394393
pathContext.WorkingDirectory,
395394
$"push {nupkgToPush} -Source {sourceName} -Timeout 110",
396395
timeOutInMilliseconds: 120000,
397-
testOutputHelper: _testOutputHelper); // 120 seconds
396+
logLine: _testOutputHelper.WriteLine); // 120 seconds
398397
}
399398

400399
//Assert
@@ -438,7 +437,7 @@ public void PushCommand_Server_Nupkg_ByFilename_SnupkgDoesNotExist_NoFileNotFoun
438437
pathContext.WorkingDirectory,
439438
$"push {nupkgFullPath} -Source {sourceName} -Timeout 110",
440439
timeOutInMilliseconds: 120000,
441-
testOutputHelper: _testOutputHelper); // 120 seconds
440+
logLine: _testOutputHelper.WriteLine); // 120 seconds
442441
}
443442

444443
// Assert
@@ -479,7 +478,7 @@ public void PushCommand_Server_Nupkg_ByWildcard_SnupkgDoesNotExist_NoFileNotFoun
479478
pathContext.WorkingDirectory,
480479
$"push {pushArgument} -Source {sourceName} -Timeout 110",
481480
timeOutInMilliseconds: 120000,
482-
testOutputHelper: _testOutputHelper); // 120 seconds
481+
logLine: _testOutputHelper.WriteLine); // 120 seconds
483482
}
484483

485484
// Assert
@@ -531,15 +530,15 @@ public void PushCommand_Server_Nupkg_ByFilename_SnupkgExists_Conflict()
531530
pathContext.WorkingDirectory,
532531
$"push {nupkgFullPath} -Source {sourceName} -Timeout 110",
533532
timeOutInMilliseconds: 120000,
534-
testOutputHelper: _testOutputHelper); // 120 seconds
533+
logLine: _testOutputHelper.WriteLine); // 120 seconds
535534

536535
//Second run with SkipDuplicate
537536
result2 = CommandRunner.Run(
538537
nuget,
539538
pathContext.WorkingDirectory,
540539
$"push {nupkgFullPath} -Source {sourceName} -Timeout 110 -SkipDuplicate",
541540
timeOutInMilliseconds: 120000,
542-
testOutputHelper: _testOutputHelper); // 120 seconds
541+
logLine: _testOutputHelper.WriteLine); // 120 seconds
543542
}
544543

545544
// Assert
@@ -599,7 +598,7 @@ public void PushCommand_Server_Nupkg_ByWildcard_NupkgAndSnupkgPushed()
599598
pathContext.WorkingDirectory,
600599
$"push {wildcardPush} -Source {sourceName} -Timeout 110",
601600
timeOutInMilliseconds: 120000,
602-
testOutputHelper: _testOutputHelper); // 120 seconds
601+
logLine: _testOutputHelper.WriteLine); // 120 seconds
603602
}
604603

605604
// Assert
@@ -655,7 +654,7 @@ public void PushCommand_Server_Nupkg_ByWildcard_SeparateSymbolUrl_NupkgAndSnupkg
655654
pathContext.WorkingDirectory,
656655
$"push {wildcardPush} -Source {sourceName} -SymbolSource {symbolSourceName} -Timeout 110",
657656
timeOutInMilliseconds: 120000,
658-
testOutputHelper: _testOutputHelper); // 120 seconds
657+
logLine: _testOutputHelper.WriteLine); // 120 seconds
659658
}
660659

661660
// Assert
@@ -711,7 +710,7 @@ public void PushCommand_Server_Nupkg_SeparateSymbolUrl_NoSymbolTrue_SnupkgNotPus
711710
pathContext.WorkingDirectory,
712711
$"push {wildcardPush} -Source {sourceName} -SymbolSource {symbolPushUrl} -noSymbol -Timeout 110",
713712
timeOutInMilliseconds: 120000,
714-
testOutputHelper: _testOutputHelper); // 120 seconds
713+
logLine: _testOutputHelper.WriteLine); // 120 seconds
715714
}
716715

717716
// Assert
@@ -766,7 +765,7 @@ public void PushCommand_Server_Nupkg_ByWildcard_FindsMatchingSnupkgs_Conflict()
766765
pathContext.WorkingDirectory,
767766
$"push {wildcardPush} -Source {sourceName} -SymbolSource {sourceName} -Timeout 110",
768767
timeOutInMilliseconds: 120000,
769-
testOutputHelper: _testOutputHelper); // 120 seconds
768+
logLine: _testOutputHelper.WriteLine); // 120 seconds
770769
}
771770

772771
// Assert
@@ -830,7 +829,7 @@ public void PushCommand_Server_Nupkg_ByWildcard_FindsMatchingSnupkgs_SkipDuplica
830829
pathContext.WorkingDirectory,
831830
$"push {wildcardPush} -Source {sourceName} -Timeout 110 -SkipDuplicate",
832831
timeOutInMilliseconds: 120000,
833-
testOutputHelper: _testOutputHelper); // 120 seconds
832+
logLine: _testOutputHelper.WriteLine); // 120 seconds
834833
}
835834

836835
// Assert
@@ -890,7 +889,7 @@ public void PushCommand_Server_Snupkg_ByWildcard_FindsMatchingSnupkgs_Conflict()
890889
pathContext.WorkingDirectory,
891890
$"push {wildcardPush} -Source {sourceName} -Timeout 110",
892891
timeOutInMilliseconds: 120000,
893-
testOutputHelper: _testOutputHelper); // 120 seconds
892+
logLine: _testOutputHelper.WriteLine); // 120 seconds
894893
}
895894

896895
// Assert
@@ -953,7 +952,7 @@ public void PushCommand_Server_Snupkg_ByWildcard_FindsMatchingSnupkgs_SkipDuplic
953952
pathContext.WorkingDirectory,
954953
$"push {wildcardPush} -Source {sourceName} -Timeout 110 -SkipDuplicate",
955954
timeOutInMilliseconds: 120000,
956-
testOutputHelper: _testOutputHelper); // 120 seconds
955+
logLine: _testOutputHelper.WriteLine); // 120 seconds
957956
}
958957
// Assert
959958

@@ -1006,14 +1005,14 @@ public void PushCommand_Server_Snupkg_ByFilename_SnupkgExists_Conflict_ServerMes
10061005
pathContext.WorkingDirectory,
10071006
$"push {snupkgFileName} -Source {sourceName} -Timeout 110 -Verbosity detailed",
10081007
timeOutInMilliseconds: 120000,
1009-
testOutputHelper: _testOutputHelper); // 120 seconds
1008+
logLine: _testOutputHelper.WriteLine); // 120 seconds
10101009

10111010
result2 = CommandRunner.Run(
10121011
nuget,
10131012
pathContext.WorkingDirectory,
10141013
$"push {snupkgFileName} -Source {sourceName} -Timeout 110 -SkipDuplicate -Verbosity detailed",
10151014
timeOutInMilliseconds: 120000,
1016-
testOutputHelper: _testOutputHelper); // 120 seconds
1015+
logLine: _testOutputHelper.WriteLine); // 120 seconds
10171016
}
10181017

10191018
// Assert
@@ -1045,7 +1044,7 @@ public void PushCommand_WhenPushingToAnHttpServerV3_WithSymbols_Errors()
10451044
packageDirectory,
10461045
$"push {snupkgFileName} -Source {sourceName} -Timeout 110 -Verbosity detailed",
10471046
timeOutInMilliseconds: 120000,
1048-
testOutputHelper: _testOutputHelper); // 120 seconds
1047+
logLine: _testOutputHelper.WriteLine); // 120 seconds
10491048

10501049
// Assert
10511050
Assert.False(result.Success, result.AllOutput);

test/NuGet.Clients.FuncTests/NuGet.CommandLine.FuncTest/Commands/RestoreCommandSignPackagesTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
using NuGet.Test.Utility;
2020
using Test.Utility.Signing;
2121
using Xunit;
22-
using Xunit.Abstractions;
2322

2423
namespace NuGet.CommandLine.FuncTest.Commands
2524
{
@@ -435,7 +434,7 @@ public CommandRunnerResult RunRestore(string nugetExe, SimpleTestPathContext pat
435434
pathContext.WorkingDirectory,
436435
string.Join(" ", args),
437436
environmentVariables: envVars,
438-
testOutputHelper: _testOutputHelper);
437+
logLine: _testOutputHelper.WriteLine);
439438

440439
// Assert
441440
Assert.True(expectedExitCode == r.ExitCode, r.AllOutput);

test/NuGet.Clients.FuncTests/NuGet.CommandLine.FuncTest/Commands/RestoreCommandTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
using NuGet.Versioning;
2424
using Test.Utility;
2525
using Xunit;
26-
using Xunit.Abstractions;
2726

2827
namespace NuGet.CommandLine.FuncTest.Commands
2928
{
@@ -987,7 +986,7 @@ public CommandRunnerResult RunRestore(SimpleTestPathContext pathContext, int exp
987986
pathContext.WorkingDirectory.Path,
988987
string.Join(" ", args),
989988
environmentVariables: envVars,
990-
testOutputHelper: _testOutputHelper);
989+
logLine: _testOutputHelper.WriteLine);
991990

992991
// Assert
993992
Assert.True(expectedExitCode == r.ExitCode, r.AllOutput);

0 commit comments

Comments
 (0)