Use vstest Cobertura support (#1177)

* Use vstest Cobertura support

Thanks to https://github.com/microsoft/vstest/issues/2874 Cobertura reports can be obtained faster without coverlet.

* Update Kubectl.Tests.csproj

* Update KubernetesClient.Classic.Tests.csproj

* Update KubernetesClient.Tests.csproj

* Update buildtest.yaml

* Update AbstractKubernetes.cs.template

* Update IBasicKubernetes.cs.template

* Update IOperations.cs.template

* Update Model.cs.template

* Add filter

* revert
This commit is contained in:
stan-sz
2023-02-11 14:31:30 +01:00
committed by GitHub
parent 10f4951dd5
commit 84da0571a3
5 changed files with 57 additions and 21 deletions

View File

@@ -24,7 +24,18 @@ jobs:
- name: Build - name: Build
run: dotnet build --configuration Release -v detailed run: dotnet build --configuration Release -v detailed
- name: Test - name: Test
run: dotnet test /p:CollectCoverage=true /p:ExcludeByFile=\"**/KubernetesClient/generated/**/*.cs\" /p:CoverletOutputFormat="cobertura" run: dotnet test --configuration Release --collect:"Code Coverage;Format=Cobertura" --logger trx --results-directory TestResults --settings CodeCoverage.runsettings --no-build
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
directory: ./TestResults
files: '*.cobertura.xml'
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: test-results
path: ./TestResults
if: ${{ always() }} # Always run this step even on failure
# Test code gen for visual studio compatibility >> https://github.com/kubernetes-client/csharp/pull/1008 # Test code gen for visual studio compatibility >> https://github.com/kubernetes-client/csharp/pull/1008
codgen: codgen:

40
CodeCoverage.runsettings Normal file
View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Include>
<ModulePath>.*KubernetesClient\..*\.dll$</ModulePath>
</Include>
<Exclude>
<ModulePath>.*tests\.dll$</ModulePath>
<ModulePath>.*xunit.*dll$</ModulePath>
<ModulePath>.*moq\.dll$</ModulePath>
<ModulePath>.*System\.Reactive\.dll$</ModulePath>
<ModulePath>.*BouncyCastle\.Crypto\.dll$</ModulePath>
<ModulePath>.*IdentityModel\.OidcClient\.dll$</ModulePath>
</Exclude>
</ModulePaths>
<!-- Set this to True to collect coverage information for functions marked with the "SecuritySafeCritical" attribute. Instead of writing directly into a memory location from such functions, code coverage inserts a probe that redirects to another function, which in turns writes into memory. -->
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<!-- When set to True, collects coverage information from child processes that are launched with low-level ACLs, for example, UWP apps. -->
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<!-- When set to True, collects coverage information from child processes that are launched by test or production code. -->
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<Attributes>
<Exclude>
<Attribute>^System.ObsoleteAttribute$</Attribute>
<Attribute>^System.CodeDom.Compiler.GeneratedCodeAttribute$</Attribute>
<Attribute>^System.Diagnostics.DebuggerHiddenAttribute$</Attribute>
<Attribute>^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$</Attribute>
</Exclude>
</Attributes>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>

View File

@@ -9,11 +9,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">

View File

@@ -18,11 +18,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">

View File

@@ -17,11 +17,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">