Skip to content

Commit

Permalink
Update XUnit to 2.4.2-pre.22 (#63948)
Browse files Browse the repository at this point in the history
* Update to Xunit build 2.4.2-pre.13

Also pick up latest pre-release of analyzers

* Disambiguate calls to Assert.Equals(double,double,int)

Xunit added a new Assert overload that caused a lot of ambiguous calls.
xunit/xunit#2393

Workaround by casting to double.

* Fix new instances of xUnit2000 diagnostic

* Workaround xUnit2002 issue with implicit cast

Works around xunit/xunit#2395

* Disable xUnit2014 diagnostic

This diagnostic forces the use of Assert.ThrowsAsync for any async method,
however in our case we may want to test that a method will throw
synchronously to avoid regressing that behavior by moving to the async
portion of the method.

* Use AssertExtensions to test for null ArgumentException.ParamName

Workaround xunit/xunit#2396

* Update to Xunit 2.4.2-pre.22

* Fix another ArugmentException.ParamName == null assert
  • Loading branch information
ericstj committed Jan 20, 2022
1 parent 18b0540 commit 1d751ba
Show file tree
Hide file tree
Showing 51 changed files with 322 additions and 318 deletions.
2 changes: 1 addition & 1 deletion eng/CodeAnalysis.test.globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ dotnet_diagnostic.xUnit2012.severity = warning
dotnet_diagnostic.xUnit2013.severity = none

# xUnit2014: Do not use throws check to check for asynchronously thrown exception
dotnet_diagnostic.xUnit2014.severity = warning
dotnet_diagnostic.xUnit2014.severity = none

# xUnit2015: Do not use typeof expression to check the exception type
dotnet_diagnostic.xUnit2015.severity = warning
Expand Down
3 changes: 2 additions & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>1.0.0-prerelease.22067.1</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
<MicrosoftDotNetXHarnessCLIVersion>1.0.0-prerelease.22067.1</MicrosoftDotNetXHarnessCLIVersion>
<MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion>1.0.2-alpha.0.22060.2</MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion>
<XUnitVersion>2.4.2-pre.9</XUnitVersion>
<XUnitVersion>2.4.2-pre.22</XUnitVersion>
<XUnitAnalyzersVersion>0.12.0-pre.20</XUnitAnalyzersVersion>
<XUnitRunnerVisualStudioVersion>2.4.2</XUnitRunnerVisualStudioVersion>
<CoverletCollectorVersion>3.1.0</CoverletCollectorVersion>
<NewtonsoftJsonVersion>12.0.3</NewtonsoftJsonVersion>
Expand Down
1 change: 1 addition & 0 deletions eng/testing/xunit/xunit.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<!-- Excluding xunit.core/build as it enables deps file generation. -->
<PackageReference Include="xunit" Version="$(XUnitVersion)" ExcludeAssets="build" />
<PackageReference Include="xunit.analyzers" Version="$(XUnitAnalyzersVersion)" ExcludeAssets="build" />
<PackageReference Include="Microsoft.DotNet.XUnitExtensions" Version="$(MicrosoftDotNetXUnitExtensionsVersion)" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ IEnumerable<Func<Stream, Stream>> CtorFunctions()
}
else
{
Assert.Equal(data2[i], (byte)0);
Assert.Equal((byte)0, data2[i]);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void InstanceArgumentInsteadOfTypeForStaticCall()
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
}));
Func<CallSite, object, object, object, object> target = site.Target;
Assert.Throws<ArgumentException>(null, () => target.Invoke(site, "Ceci n'est pas un type", 2, 2));
AssertExtensions.Throws<ArgumentException>(null, () => target.Invoke(site, "Ceci n'est pas un type", 2, 2));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static void IListProperties()
public static void VirtualMethods()
{
VirtualTestReadOnlyCollection collectionBase = new VirtualTestReadOnlyCollection();
Assert.Equal(collectionBase.Count, int.MinValue);
Assert.Equal(int.MinValue, collectionBase.Count);
Assert.Null(collectionBase.GetEnumerator());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public void Add_SetSiteNameDuplicate_ThrowsArgumentException()
container.Add(component1, "Name1");
container.Add(component2, "Name2");

Assert.Throws<ArgumentException>(null, () => component1.Site.Name = "Name2");
AssertExtensions.Throws<ArgumentException>(null, () => component1.Site.Name = "Name2");
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void Indexer_SetNotSupported_ThrowsArgumentException(object owner)
MemberRelationship source = new MemberRelationship(owner, member);

var service = new NotSupportingMemberRelationshipService();
Assert.Throws<ArgumentException>(null, () => service[source] = source);
AssertExtensions.Throws<ArgumentException>(null, () => service[source] = source);
}

private class TestClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ public void AddService_NullServiceInstance_ThrowsArgumentNullException()
public void AddService_ServiceInstanceNotInstanceOfType_ThrowsArgumentException()
{
var container = new ServiceContainer();
Assert.Throws<ArgumentException>(null, () => container.AddService(typeof(int), new object()));
Assert.Throws<ArgumentException>(null, () => container.AddService(typeof(int), new object(), true));
Assert.Throws<ArgumentException>(null, () => container.AddService(typeof(int), new object(), false));
AssertExtensions.Throws<ArgumentException>(null, () => container.AddService(typeof(int), new object()));
AssertExtensions.Throws<ArgumentException>(null, () => container.AddService(typeof(int), new object(), true));
AssertExtensions.Throws<ArgumentException>(null, () => container.AddService(typeof(int), new object(), false));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public void SqlBytesMaxLength()
{
byte[] b = null;
SqlBytes bytes = new SqlBytes();
Assert.Equal(bytes.MaxLength, -1);
Assert.Equal(-1, bytes.MaxLength);
bytes = new SqlBytes(b);
Assert.Equal(bytes.MaxLength, -1);
Assert.Equal(-1, bytes.MaxLength);
b = new byte[10];
bytes = new SqlBytes(b);
Assert.Equal(10, bytes.MaxLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public void SqlCharsMaxLength()
{
char[] b = null;
SqlChars chars = new SqlChars();
Assert.Equal(chars.MaxLength, -1);
Assert.Equal(-1, chars.MaxLength);
chars = new SqlChars(b);
Assert.Equal(chars.MaxLength, -1);
Assert.Equal(-1, chars.MaxLength);
b = new char[10];
chars = new SqlChars(b);
Assert.Equal(10, chars.MaxLength);
Expand Down
Loading

0 comments on commit 1d751ba

Please sign in to comment.