Skip to content

Commit 7dc2b1f

Browse files
authored
chore: Use TUnit for the unit test, cleanup state (#1459)
* chore: Use TUnit for the unit test, cleanup state * exclude tests folders from coverage
1 parent 7172f63 commit 7dc2b1f

119 files changed

Lines changed: 6118 additions & 3223 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.

‎.claude/settings.local.json‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎CLAUDE.md‎

Lines changed: 197 additions & 114 deletions
Large diffs are not rendered by default.

‎codecov.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ignore:
2+
- src/tests
3+
- "**/Tests/"
4+
- "**/*.Tests/"
5+
- "**/*.Test/"
6+
- "**/TestRunner.*/"

‎src/Directory.Build.props‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,8 @@
6464
<TreatWarningsAsErrors>falseTreatWarningsAsErrors>
6565
PropertyGroup>
6666
<PropertyGroup Condition="'$(IsTestProject)' == 'true'">
67-
<EnableNUnitRunner>trueEnableNUnitRunner>
6867
<TestingPlatformDotnetTestSupport>trueTestingPlatformDotnetTestSupport>
69-
PropertyGroup>
70-
<PropertyGroup Condition="$(IsTestProject) or $(MSBuildProjectName.Contains('TestRunner'))">
71-
<NoWarn>$(NoWarn);CA1031;CA1034;CA1040;CA1515;CA1707;CA1852;CA2000;CA2201NoWarn>
68+
<NoWarn>$(NoWarn);CS1591NoWarn>
7269
PropertyGroup>
7370
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
7471
<ContinuousIntegrationBuild>trueContinuousIntegrationBuild>
@@ -81,17 +78,12 @@
8178
<CopyToOutputDirectory>PreserveNewestCopyToOutputDirectory>
8279
None>
8380

81+
<PackageReference Include="TUnit"/>
8482
<PackageReference Include="Microsoft.NET.Test.Sdk" />
85-
<PackageReference Include="NUnit" />
86-
<PackageReference Include="NUnit3TestAdapter" />
83+
<PackageReference Include="Verify.TUnit"/>
8784
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
88-
ItemGroup>
89-
90-
<ItemGroup Condition="$(IsTestProject) or $(MSBuildProjectName.Contains('TestRunner'))">
91-
<PackageReference Include="NUnit.Analyzers" />
9285
<PackageReference Include="Microsoft.Reactive.Testing" />
9386
<PackageReference Include="PublicApiGenerator" />
94-
<PackageReference Include="Verify.NUnit" />
9587
ItemGroup>
9688

9789
<ItemGroup Condition="'$(IsTestProject)' != 'true'">

‎src/Directory.Packages.props‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
2929
<PackageVersion Include="System.Reactive" Version="6.1.0" />
3030
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
31-
<PackageVersion Include="NUnit" Version="4.4.0" />
32-
<PackageVersion Include="NUnit3TestAdapter" Version="6.0.1" />
33-
<PackageVersion Include="NUnit.Analyzers" Version="4.11.2" />
34-
<PackageVersion Include="Verify.NUnit" Version="31.9.2" />
31+
<PackageVersion Include="TUnit" Version="1.7.7" />
32+
<PackageVersion Include="Verify.TUnit" Version="31.9.3" />
3533
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
3634
<PackageVersion Include="Microsoft.Reactive.Testing" Version="6.1.0" />
3735
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.1.0" />

‎src/Splat.Builder/AppBuilder.cs‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,30 @@ public IAppInstance Build()
158158
Current = _serviceProvider();
159159
return this;
160160
}
161+
162+
///
163+
/// Gets the current state for test isolation. Used by test scopes.
164+
///
165+
/// A tuple containing HasBeenBuilt and UsingBuilder state.
166+
internal static (bool hasBeenBuilt, bool usingBuilder) GetState() =>
167+
(HasBeenBuilt, UsingBuilder);
168+
169+
///
170+
/// Restores the state for test isolation. Used by test scopes.
171+
///
172+
/// The state to restore.
173+
internal static void RestoreState((bool hasBeenBuilt, bool usingBuilder) state)
174+
{
175+
HasBeenBuilt = state.hasBeenBuilt;
176+
UsingBuilder = state.usingBuilder;
177+
}
178+
179+
///
180+
/// Resets the state to default for test isolation. Used by test scopes.
181+
///
182+
internal static void ResetState()
183+
{
184+
HasBeenBuilt = false;
185+
UsingBuilder = false;
186+
}
161187
}

‎src/Splat.Builder/Splat.Builder.csproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<ItemGroup>
1818
<InternalsVisibleTo Include="Splat" />
1919
<InternalsVisibleTo Include="Splat.Tests" />
20+
<InternalsVisibleTo Include="Splat.Common.Test" />
2021
<InternalsVisibleTo Include="Splat.Drawing" />
2122
<InternalsVisibleTo Include="Splat.Drawing.Tests" />
2223
<InternalsVisibleTo Include="Splat.TestRunner.Android" />

‎src/Splat.Core/Polyfills/CallerArgumentExpressionAttribute.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace System.Runtime.CompilerServices;
1212

1313
///
1414
/// Indicates that a parameter captures the expression passed for another parameter as a string.
15+
/// Modification of Using SimonCropp's polyfill's library.
1516
///
1617
[ExcludeFromCodeCoverage]
1718
[DebuggerNonUserCode]

‎src/Splat.Core/Polyfills/DoesNotReturnIfAttribute.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace System.Diagnostics.CodeAnalysis;
1212

1313
///
1414
/// Indicates that a parameter captures the expression passed for another parameter as a string.
15+
/// Modification of Using SimonCropp's polyfill's library.
1516
///
1617
[ExcludeFromCodeCoverage]
1718
[DebuggerNonUserCode]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright (c) 2025 ReactiveUI. All rights reserved.
2+
// Licensed to ReactiveUI under one or more agreements.
3+
// ReactiveUI licenses this file to you under the MIT license.
4+
// See the LICENSE file in the project root for full license information.
5+
6+
#if !NET
7+
8+
using System.Diagnostics;
9+
using System.Diagnostics.CodeAnalysis;
10+
11+
namespace System.Runtime.CompilerServices;
12+
13+
///
14+
/// Reserved to be used by the compiler for tracking metadata. This class should not be used by developers in source code.
15+
/// Modification of Using SimonCropp's polyfill's library.
16+
///
17+
[ExcludeFromCodeCoverage]
18+
[DebuggerNonUserCode]
19+
internal static class IsExternalInit;
20+
21+
#else
22+
using System.Runtime.CompilerServices;
23+
24+
[assembly: TypeForwardedTo(typeof(IsExternalInit))]
25+
#endif

0 commit comments

Comments
 (0)