Skip to content

Commit

Permalink
Switch to Microsoft.Testing.Platform (#250)
Browse files Browse the repository at this point in the history
* Switch to MTP.

* Update snapshots.

* Trying to fix CICD error.

* Replace coverlet with Microsoft package.

* Minor edit to fix linter warning.

* Update runsettings

* Add extensions for hangdump and crashdump.

* Update CICD job to run tests.

* Fix build

* Try something else + fix typo.

* Various updates

* Set output type to Library to fix error hopefully.

* Update snapshots.

* Set output type to back to exe.

* Fix references.

* Exclude from code coverage.
  • Loading branch information
AjayKMehta authored Feb 24, 2025
1 parent 2a00dc0 commit f513ab7
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 226 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ csharp_preferred_modifier_order = public,private,protected,internal,static,exter
csharp_prefer_static_local_function = true
csharp_style_expression_bodied_local_functions = when_on_single_line
dotnet_style_readonly_field = true
dotnet_style_require_accessibility_modifiers = always
dotnet_style_require_accessibility_modifiers = for_non_interface_members

# Parentheses preferences
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0047-ide0048#dotnet_style_parentheses_in_arithmetic_binary_operators
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
TESTINGPLATFORM_DIAGNOSTIC: 1
TESTINGPLATFORM_DIAGNOSTIC_VERBOSITY: Information

steps:
- name: 'Checkout Repository'
Expand Down Expand Up @@ -104,7 +106,7 @@ jobs:

- name: Test
if: env.ENABLED == '1'
run: dotnet test --configuration Release -s cicd.runsettings --no-build --verbosity quiet --logger "GitHubActions;summary.includeNotFoundTests=false"
run: dotnet test -s ./cicd.runsettings --configuration Release --no-build --verbosity quiet --logger "GitHubActions;summary.includeNotFoundTests=false" -- --coverage --coverage-output-format xml --coverage-output coverage.cobertura.xml --crashdump --hangdump

- name: ReportGenerator
if: env.ENABLED == '1'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ bld/
**/[Bb]in/
**/[Oo]bj/
**/[Ll]og/
[Ll]ogs/

# Visual Studio 2015/2017 cache/options directory
.vs/
Expand Down
14 changes: 9 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@
<NoWarn>$(NoWarn);NU1507</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageVersion Include="IDisposableAnalyzers" Version="4.0.8" />
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="6.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.CrashDump" Version="1.6.2" />
<PackageVersion Include="Microsoft.Testing.Extensions.HangDump" Version="1.6.2" />
<PackageVersion Include="NUnit" Version="4.3.2" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageVersion Include="NUnit.Analyzers" Version="4.6.0" />
<PackageVersion Include="ReflectionAnalyzers" Version="0.3.1" />
<PackageVersion Include="Verify.NUnit" Version="28.9.0" />
<PackageVersion Include="Verify.NUnit" Version="28.12.0" />
<PackageVersion Include="Verify.SourceGenerators" Version="2.5.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.VSTestBridge" Version="1.6.2" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="17.14.1" />
</ItemGroup>
</Project>
</Project>
76 changes: 0 additions & 76 deletions cicd.runsettings
Original file line number Diff line number Diff line change
Expand Up @@ -4,89 +4,13 @@
<!-- https://github.com/microsoft/codecoverage/blob/main/docs/configuration.md -->
<RunSettings>
<RunConfiguration>
<TargetPlatform>x64</TargetPlatform>
<TreatTestAdapterErrorsAsWarnings>False </TreatTestAdapterErrorsAsWarnings>
<ResultsDirectory>./TestResults</ResultsDirectory>
<MaxCpuCount>3</MaxCpuCount>
<!-- Timeout in milliseconds. If 0, timeout will be infinity -->
<TestSessionTimeout>60000</TestSessionTimeout>
<TreatNoTestsAsError>False</TreatNoTestsAsError>
<!-- Disables in-assembly parallel execution. -->
<DisableParallelization>False</DisableParallelization>
<DisableAppDomain>False</DisableAppDomain>
<CollectSourceInformation>True</CollectSourceInformation>
</RunConfiguration>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CoverageLogLevel>Dumps</CoverageLogLevel>
<InstrumentationLogLevel>Dumps</InstrumentationLogLevel>
<CoverageFileLogPath>coverage.log</CoverageFileLogPath>
<!-- Below doesn't work 😦. For details, see https://github.com/microsoft/codecoverage/issues/76 -->
<CoverageFileName>coverage.cobertura.xml</CoverageFileName>
<Format>Cobertura</Format>
<PerTestCodeCoverage>False</PerTestCodeCoverage>
<IncludeTestAssembly>False</IncludeTestAssembly>
<CodeCoverage>
<CommunicationTimeout> 120000</CommunicationTimeout>
<ModulePaths>
<Exclude>
<ModulePath>.*Tests\.dll$</ModulePath>
<ModulePath>.*Argon.*\.dll$</ModulePath>
</Exclude>
</ModulePaths>
<Attributes>
<Exclude>
<Attribute>^System\.Diagnostics\.DebuggerHiddenAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.DebuggerNonUserCodeAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
<Attribute>^System\.ObsoleteAttribute$</Attribute>
<Attribute>^System\.Text\.RegularExpressions\.GeneratedRegexAttribute$</Attribute>
<Attribute>^System\.Runtime\.CompilerServices\.CompilerGeneratedAttribute$</Attribute>
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
</Exclude>
</Attributes>
<!-- Match the company name property in the assembly: -->
<CompanyNames>
<Exclude>
<CompanyName>.*microsoft.*</CompanyName>
</Exclude>
</CompanyNames>
<Sources>
<Exclude>
<Source>.*EquatableArray\.cs</Source>
</Exclude>
</Sources>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<UseVerifiableInstrumentation>False</UseVerifiableInstrumentation>
<EnableStaticNativeInstrumentation>False</EnableStaticNativeInstrumentation>
<EnableDynamicNativeInstrumentation>False</EnableDynamicNativeInstrumentation>
<EnableDynamicManagedInstrumentation>True</EnableDynamicManagedInstrumentation>
<EnableStaticManagedInstrumentation>True</EnableStaticManagedInstrumentation>
<ExcludeAssembliesWithoutSources>MissingAll</ExcludeAssembliesWithoutSources>
</CodeCoverage>
</Configuration>
</DataCollector>
<!-- Isolate test causing crash. -->
<DataCollector friendlyName="blame" enabled="True">
<Configuration>
<CollectDump DumpType="Full" />
<CollectDumpOnTestSessionHang TestTimeout="10min" HangDumpType="Full" />
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<LoggerRunSettings>
<Loggers>
<Logger friendlyName="console" enabled="true">
<Configuration>
<Verbosity>normal</Verbosity>
</Configuration>
</Logger>
<Logger friendlyName="blame" enabled="true" />
</Loggers>
</LoggerRunSettings>
<!-- https://docs.nunit.org/articles/vs-test-adapter/Tips-And-Tricks.html -->
<NUnit>
<PrivateBinPath>extras;more.extras</PrivateBinPath>
Expand Down
88 changes: 0 additions & 88 deletions local.runsettings
Original file line number Diff line number Diff line change
Expand Up @@ -4,101 +4,13 @@
<!-- https://github.com/microsoft/codecoverage/blob/main/docs/configuration.md -->
<RunSettings>
<RunConfiguration>
<TargetPlatform>x64</TargetPlatform>
<TreatTestAdapterErrorsAsWarnings>False </TreatTestAdapterErrorsAsWarnings>
<!-- Path relative to solution directory -->
<ResultsDirectory>./TestResults</ResultsDirectory>
<!-- 0 allows as many testhosts as you have logical processors -->
<MaxCpuCount>0</MaxCpuCount>
<!-- Timeout in milliseconds. If 0, timeout will be infinity -->
<TestSessionTimeout>3600000</TestSessionTimeout>
<TreatNoTestsAsError>False</TreatNoTestsAsError>
<!-- Disables in-assembly parallel execution. -->
<DisableParallelization>False</DisableParallelization>
<DisableAppDomain>False</DisableAppDomain>
<CollectSourceInformation>True</CollectSourceInformation>
</RunConfiguration>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CoverageLogLevel>Dumps</CoverageLogLevel>
<InstrumentationLogLevel>Dumps</InstrumentationLogLevel>
<CoverageFileLogPath>coverage.log</CoverageFileLogPath>
<!-- Below doesn't work 😦. For details, see https://github.com/microsoft/codecoverage/issues/76 -->
<CoverageFileName>coverage.cobertura.xml</CoverageFileName>
<Format>Cobertura</Format>
<PerTestCodeCoverage>False</PerTestCodeCoverage>
<IncludeTestAssembly>False</IncludeTestAssembly>
<CodeCoverage>
<CommunicationTimeout> 120000</CommunicationTimeout>
<ModulePaths>
<Exclude>
<ModulePath>.*Tests\.dll$</ModulePath>
<ModulePath>.*Argon.*\.dll$</ModulePath>
</Exclude>
</ModulePaths>
<Attributes>
<Exclude>
<Attribute>^System\.Diagnostics\.DebuggerHiddenAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.DebuggerNonUserCodeAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
<Attribute>^System\.ObsoleteAttribute$</Attribute>
<Attribute>^System\.Text\.RegularExpressions\.GeneratedRegexAttribute$</Attribute>
<Attribute>^System\.Runtime\.CompilerServices\.CompilerGeneratedAttribute$</Attribute>
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
</Exclude>
</Attributes>
<!-- Match the company name property in the assembly: -->
<CompanyNames>
<Exclude>
<CompanyName>.*microsoft.*</CompanyName>
</Exclude>
</CompanyNames>
<Sources>
<Exclude>
<Source>.*EquatableArray\.cs</Source>
</Exclude>
</Sources>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<UseVerifiableInstrumentation>False</UseVerifiableInstrumentation>
<EnableStaticNativeInstrumentation>False</EnableStaticNativeInstrumentation>
<EnableDynamicNativeInstrumentation>False</EnableDynamicNativeInstrumentation>
<EnableDynamicManagedInstrumentation>True</EnableDynamicManagedInstrumentation>
<EnableStaticManagedInstrumentation>True</EnableStaticManagedInstrumentation>
<ExcludeAssembliesWithoutSources>MissingAll</ExcludeAssembliesWithoutSources>
</CodeCoverage>
</Configuration>
</DataCollector>
<!-- Isolate test causing crash. -->
<DataCollector friendlyName="blame" enabled="True">
<Configuration>
<CollectDump DumpType="Full" />
<CollectDumpOnTestSessionHang TestTimeout="10min" HangDumpType="Full" />
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<LoggerRunSettings>
<Loggers>
<Logger friendlyName="console" enabled="true">
<Configuration>
<Verbosity>normal</Verbosity>
</Configuration>
</Logger>
<Logger friendlyName="trx" enabled="true">
<Configuration>
<LogFilePrefix>testresults</LogFilePrefix>
</Configuration>
</Logger>
<Logger friendlyName="html" enabled="true">
<Configuration>
<LogFilePrefix>TestResults</LogFilePrefix>
</Configuration>
</Logger>
<Logger friendlyName="blame" enabled="true" />
</Loggers>
</LoggerRunSettings>
<!-- https://docs.nunit.org/articles/vs-test-adapter/Tips-And-Tricks.html -->
<NUnit>
<PrivateBinPath>extras;more.extras</PrivateBinPath>
Expand Down
2 changes: 2 additions & 0 deletions src/BuilderGenerator/EquatableArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace BuilderGenerator;

/// <summary>
/// An immutable, equatable array. This is equivalent to <see cref="Array"/> but with value equality support.
/// </summary>
/// <typeparam name="T">The type of values in the array.</typeparam>
[ExcludeFromCodeCoverage]
public readonly struct EquatableArray<T> : IEquatable<EquatableArray<T>>, IEnumerable<T>
where T : IEquatable<T>
{
Expand Down
3 changes: 3 additions & 0 deletions src/BuilderGenerator/PropertyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.Diagnostics.CodeAnalysis;

namespace BuilderGenerator;

[ExcludeFromCodeCoverage]
public record PropertyInfo
{
public string PropertyName { get; }
Expand Down
17 changes: 11 additions & 6 deletions tests/BuilderGenerator.Tests/BuilderGenerator.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<!-- https://docs.nunit.org/articles/vs-test-adapter/NUnit-And-Microsoft-Test-Platform.html -->
<EnableNUnitRunner>true</EnableNUnitRunner>
<OutputType>Exe</OutputType>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger">
Expand All @@ -13,13 +19,12 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Testing.Extensions.CrashDump" />
<PackageReference Include="Microsoft.Testing.Extensions.HangDump" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NUnit.Analyzers" PrivateAssets="all" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
<PackageReference Include="ReflectionAnalyzers">
<IncludeAssets>runtime; build; native;
contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -34,4 +39,4 @@
<ItemGroup>
<Folder Include="Snapshots\" />
</ItemGroup>
</Project>
</Project>
Loading

0 comments on commit f513ab7

Please sign in to comment.