Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade xunit to v3 #710

Merged
merged 4 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_space_around_binary_operators = before_and_after

# xunit Analyzers
dotnet_diagnostic.xUnit1051.severity = none # Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive

[*.{cs,vb}]
#### Naming styles ####

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,13 @@ jobs:
# nats-server.exe -v
# dotMemoryUnit $env:userprofile\.dotnet\tools\nunit.exe --propagate-exit-code -- .\tests\NATS.Client.Core.MemoryTests\bin\Release\net6.0\NATS.Client.Core.MemoryTests.dll

# fails when target frameworks are run in parallel; run tests with -p:TestTfmsInParallel=false
mtmk marked this conversation as resolved.
Show resolved Hide resolved
- name: Platform Test
run: |
tasklist | grep -i nats-server && taskkill -F -IM nats-server.exe
nats-server.exe -v
cd tests\NATS.Client.Platform.Windows.Tests
dotnet test -c Release --no-build
dotnet test -c Release --no-build -p:TestTfmsInParallel=false

# Not working on Windows reliably yet
#- name: Test Core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.v3.assert" Version="1.0.1" />
<Using Include="Xunit" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\NATS.Client.Core\NATS.Client.Core.csproj" />
<ProjectReference Include="..\..\src\NATS.Client.JetStream\NATS.Client.JetStream.csproj" />
<ProjectReference Include="..\NATS.Client.Core.Tests\NATS.Client.Core.Tests.csproj" />
<ProjectReference Include="..\NATS.Client.TestUtilities\NATS.Client.TestUtilities.csproj" />
</ItemGroup>

</Project>
12 changes: 0 additions & 12 deletions tests/NATS.Client.Core.MemoryTests/NatsConsumeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using NATS.Client.JetStream;
using NATS.Client.JetStream.Internal;
using NATS.Client.JetStream.Models;
using Xunit.Abstractions;

namespace NATS.Client.Core.MemoryTests;

Expand Down Expand Up @@ -193,14 +192,3 @@ public void Subscription_should_not_be_collected_when_in_ordered_consume_async_e
}
}
}

public class TestTextWriterOutput : ITestOutputHelper
{
private readonly TextWriter _out;

public TestTextWriterOutput(TextWriter @out) => _out = @out;

public void WriteLine(string message) => _out.WriteLine(message);

public void WriteLine(string format, params object[] args) => _out.WriteLine(format, args);
}
26 changes: 12 additions & 14 deletions tests/NATS.Client.Core.Tests/NATS.Client.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,32 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.5.1"/>
<PackageReference Include="ProcessX" Version="1.5.4"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0"/>
<PackageReference Include="xunit" Version="2.4.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="FluentAssertions" Version="6.5.1" />
<PackageReference Include="ProcessX" Version="1.5.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
<Using Include="Xunit.Abstractions"/>
<Using Include="FluentAssertions"/>
<Using Include="NATS.Client.Core"/>
<Using Include="NATS.Client.Core.Internal"/>
<Using Include="NATS.Client.Core.Commands"/>
<Using Include="Xunit" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client.Core" />
<Using Include="NATS.Client.Core.Internal" />
<Using Include="NATS.Client.Core.Commands" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NATS.Client.Serializers.Json\NATS.Client.Serializers.Json.csproj" />
<ProjectReference Include="..\NATS.Client.TestUtilities\NATS.Client.TestUtilities.csproj"/>
<ProjectReference Include="..\..\src\NATS.Client.Core\NATS.Client.Core.csproj"/>
<ProjectReference Include="..\NATS.Client.TestUtilities\NATS.Client.TestUtilities.csproj" />
<ProjectReference Include="..\..\src\NATS.Client.Core\NATS.Client.Core.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions tests/NATS.Client.Core.Tests/TlsOptsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ static async Task ValidateAsync(NatsTlsOpts opts)
}
}

[SkippableTheory]
[Theory]
[InlineData("resources/certs/client-cert.pem", "resources/certs/client-key.pem", null, 6)]
[InlineData(null, null, "resources/certs/client-cert-bundle.pfx", 6)]
[InlineData("resources/certs/chainedclient-cert.pem", "resources/certs/chainedclient-key.pem", null, 8)]
[InlineData(null, null, "resources/certs/chainedclient-cert-bundle.pfx", 8)]
public async Task Client_connect(string? clientCertFile, string? clientKeyFile, string? clientCertBundleFile, int minimumFrameworkVersion)
{
var version = int.Parse(Regex.Match(RuntimeInformation.FrameworkDescription, @"(\d+)\.\d").Groups[1].Value);
Skip.IfNot(version >= minimumFrameworkVersion, $"Requires .NET {minimumFrameworkVersion}");
Assert.SkipUnless(version >= minimumFrameworkVersion, $"Requires .NET {minimumFrameworkVersion}");

const string caFile = "resources/certs/ca-cert.pem";

Expand Down
29 changes: 14 additions & 15 deletions tests/NATS.Client.Core2.Tests/NATS.Client.Core2.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net481</TargetFrameworks>
<RuntimeIdentifiers Condition="'$(OS)' == 'Windows_NT'">any;win-x86</RuntimeIdentifiers>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);CS8002</NoWarn>
Expand All @@ -12,44 +13,42 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.5.1"/>
<PackageReference Include="ProcessX" Version="1.5.4"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0"/>
<PackageReference Include="xunit" Version="2.4.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="FluentAssertions" Version="6.5.1" />
<PackageReference Include="ProcessX" Version="1.5.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
<Using Include="Xunit.Abstractions"/>
<Using Include="FluentAssertions"/>
<Using Include="NATS.Client.Core"/>
<Using Include="NATS.Client.Core.Internal"/>
<Using Include="NATS.Client.Core.Commands"/>
<Using Include="Xunit" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client.Core" />
<Using Include="NATS.Client.Core.Internal" />
<Using Include="NATS.Client.Core.Commands" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NATS.Client.Serializers.Json\NATS.Client.Serializers.Json.csproj" />
<ProjectReference Include="..\..\src\NATS.Client.Core\NATS.Client.Core.csproj"/>
<ProjectReference Include="..\..\src\NATS.Client.Core\NATS.Client.Core.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="..\NATS.Client.Core.Tests\resources\**\*">
<Link>resources\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<Compile Include="..\NATS.Client.Platform.Windows.Tests\NatsServerProcess.cs" />
<Compile Include="..\NATS.Client.TestUtilities\InMemoryTestLoggerFactory.cs" />
Expand Down
25 changes: 12 additions & 13 deletions tests/NATS.Client.CoreUnit.Tests/NATS.Client.CoreUnit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net481</TargetFrameworks>
<RuntimeIdentifiers Condition="'$(OS)' == 'Windows_NT'">any;win-x86</RuntimeIdentifiers>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);CS8002</NoWarn>
Expand All @@ -12,35 +13,33 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.5.1"/>
<PackageReference Include="ProcessX" Version="1.5.4"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0"/>
<PackageReference Include="xunit" Version="2.4.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="FluentAssertions" Version="6.5.1" />
<PackageReference Include="ProcessX" Version="1.5.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
<Using Include="Xunit.Abstractions"/>
<Using Include="FluentAssertions"/>
<Using Include="NATS.Client.Core"/>
<Using Include="NATS.Client.Core.Internal"/>
<Using Include="NATS.Client.Core.Commands"/>
<Using Include="Xunit" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client.Core" />
<Using Include="NATS.Client.Core.Internal" />
<Using Include="NATS.Client.Core.Commands" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NATS.Client.Serializers.Json\NATS.Client.Serializers.Json.csproj" />
<ProjectReference Include="..\..\src\NATS.Client.Core\NATS.Client.Core.csproj"/>
<ProjectReference Include="..\..\src\NATS.Client.Core\NATS.Client.Core.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -21,7 +21,6 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<Using Include="Xunit" />
<Using Include="Xunit.Abstractions" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client.Core" />
<Using Include="NATS.Client.Core.Internal" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -21,7 +21,6 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<Using Include="Xunit" />
<Using Include="Xunit.Abstractions" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client.Core" />
<Using Include="NATS.Client.Core.Internal" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -21,7 +21,6 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<Using Include="Xunit" />
<Using Include="Xunit.Abstractions" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client.Core" />
<Using Include="NATS.Client.Core.Internal" />
Expand Down
1 change: 0 additions & 1 deletion tests/NATS.Client.Platform.Windows.Tests/BasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using NATS.Client.ObjectStore;
using NATS.Client.Serializers.Json;
using NATS.Client.Services;
using Xunit.Abstractions;

namespace NATS.Client.Platform.Windows.Tests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net6.0;net8.0;net481</TargetFrameworks>
<RuntimeIdentifiers>any;win-x86</RuntimeIdentifiers>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);CS8002;VSTHRD200;VSTHRD111</NoWarn>
Expand All @@ -12,16 +13,19 @@

<ItemGroup>
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageReference Include="xunit" Version="2.5.3"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3"/>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion tests/NATS.Client.Platform.Windows.Tests/TlsTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Security.Authentication;
using NATS.Client.Core;
using Xunit.Abstractions;

namespace NATS.Client.Platform.Windows.Tests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -21,7 +21,6 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<Using Include="Xunit" />
<Using Include="Xunit.Abstractions" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client.Core" />
<Using Include="NATS.Client.Services" />
Expand Down
Loading
Loading