Skip to content

Commit

Permalink
Replace xUnit with mstest (#1883)
Browse files Browse the repository at this point in the history
xUnit is no longer able to run tests on UWP. MSTest supports this in Visual Studio 2022, so we are moving back to MSTest. (Rx used to used MSTest before, so this was a relatively straightforward change.)

We had to make a few changes due to the fact that xUnit supplies a SynchronizationContext whereas MSTest does not.

Also fixed a race condition in CreateAsyncTest.
  • Loading branch information
idg10 committed Mar 30, 2023
1 parent 38e6196 commit 44a28a8
Show file tree
Hide file tree
Showing 211 changed files with 4,684 additions and 4,058 deletions.
2 changes: 1 addition & 1 deletion AsyncRx.NET/Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</ItemGroup>

<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<PackageReference Include="coverlet.collector" Version="3.1.0" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Ix.NET/Source/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</ItemGroup>

<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<PackageReference Include="coverlet.collector" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
</ItemGroup>


Expand Down
13 changes: 7 additions & 6 deletions Rx.NET/Integration/LinuxTests/LinuxTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="System.Reactive" Version="5.1.0-preview*" />
<PackageReference Include="Microsoft.Reactive.Testing" Version="5.1.0-preview*" />
<PackageReference Include="System.Reactive.Observable.Aliases" Version="5.1.0-preview*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="xunit.assert" Version="2.4.2" />
<PackageReference Include="System.Reactive" Version="6.0.0-preview*" />
<PackageReference Include="Microsoft.Reactive.Testing" Version="6.0.0-preview*" />
<PackageReference Include="System.Reactive.Observable.Aliases" Version="6.0.0-preview*" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="System.Reactive" Version="5.1.0-preview*" />
<PackageReference Include="Microsoft.Reactive.Testing" Version="5.1.0-preview*" />
<PackageReference Include="System.Reactive.Observable.Aliases" Version="5.1.0-preview*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="xunit.assert" Version="2.4.2" />
<PackageReference Include="System.Reactive" Version="6.0.0-preview*" />
<PackageReference Include="Microsoft.Reactive.Testing" Version="6.0.0-preview*" />
<PackageReference Include="System.Reactive.Observable.Aliases" Version="6.0.0-preview*" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions Rx.NET/Source/CodeCoverage.runsettings
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<MSTest>
<TestTimeout>120000</TestTimeout>
</MSTest>
</RunSettings>
2 changes: 1 addition & 1 deletion Rx.NET/Source/Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</ItemGroup>

<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<PackageReference Include="coverlet.collector" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information.

namespace Xunit.Sdk
{
/// <summary>
/// Marker interface required by xUnit.
/// </summary>
/// <remarks>
/// <para>
/// The <c>xunit.assert.source</c> package normally includes this. However, unlike all the
/// other types that package adds to our project, this one type is declared to be
/// unconditionally public.
/// </para>
/// <para>
/// We think this might be a bug: https://github.com/xunit/xunit/issues/2703
/// </para>
/// <para>
/// In any case, we do not want our library to be exporting public types in the Xunit.Sdk
/// namespace. So the csproj file carefully excludes the Asserts/Sdk/IAssertionException.cs
/// file supplied by the package (which defines this type as <c>public</c>), and this file
/// supplies an equivalent but <c>internal</c> definition.
/// </para>
/// </remarks>
internal interface IAssertionException
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@
<PackageTags>Rx;Reactive;Extensions;Observable;LINQ;Events</PackageTags>
<Description>Reactive Extensions (Rx) for .NET - Testing Library</Description>
<!-- NB: A lot of CA warnings are disabled because of the .cs files included from xunit.assert.source. -->
<NoWarn>$(NoWarn);CA1305;CA1307;CA1032;CA1064;CA1822;CA1812</NoWarn>
<NoWarn>$(NoWarn);IDE0054;IDE0066;CA1305;CA1307;CA1032;CA1064;CA1822;CA1812;CA1823</NoWarn>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="Properties\*.xml" />
<PackageReference Include="xunit.assert.source" Version="2.4.1" PrivateAssets="All" />
<PackageReference Include="xunit.assert.source" Version="2.4.2" PrivateAssets="All" />
<ProjectReference Include="..\System.Reactive\System.Reactive.csproj" />
</ItemGroup>

<ItemGroup>
<!--
Workaround for https://github.com/xunit/xunit/issues/2703
-->
<Compile Remove="$(NuGetPackageRoot)xunit.assert.source\**\contentFiles\cs\**\Asserts\Sdk\IAssertionException.cs" />
</ItemGroup>
</Project>

0 comments on commit 44a28a8

Please sign in to comment.