diff --git a/.code-coverage/coverlet.settings.xml b/.code-coverage/coverlet.settings.xml new file mode 100644 index 000000000..ec81f0fa9 --- /dev/null +++ b/.code-coverage/coverlet.settings.xml @@ -0,0 +1,12 @@ + + + + + + + cobertura,lcov + + + + + \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 7d01b676b..76c04656e 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -31,6 +31,54 @@ "reveal": "always", "panel": "dedicated" } + }, + { + "label": "test with coverage", + "command": "dotnet", + "type": "shell", + "group": "test", + "args": [ + "test", + "${workspaceFolder}/Git-Credential-Manager.sln", + "--collect", + "'XPlat Code Coverage'", + "--settings", + "${workspaceFolder}/.code-coverage/coverlet.settings.xml" + ], + "presentation": { + "reveal": "always", + "panel": "dedicated" + } + }, + { + "label": "report coverage - nix", + "command": "dotnet", + "type": "shell", + "group": "test", + "args": [ + "~/.nuget/packages/reportgenerator/*/*/net5.0/ReportGenerator.dll", + "-reports:${workspaceFolder}/**/TestResults/**/coverage.cobertura.xml", + "-targetdir:${workspaceFolder}/out/code-coverage" + ], + "presentation": { + "reveal": "always", + "panel": "dedicated" + } + }, + { + "label": "report coverage - win", + "command": "dotnet", + "type": "shell", + "group": "test", + "args": [ + "${env:USERROFILE}/.nuget/packages/reportgenerator/*/*/net5.0/ReportGenerator.dll", + "-reports:${workspaceFolder}/**/TestResults/**/coverage.cobertura.xml", + "-targetdir:${workspaceFolder}/out/code-coverage" + ], + "presentation": { + "reveal": "always", + "panel": "dedicated" + } } ] -} +} \ No newline at end of file diff --git a/docs/development.md b/docs/development.md index d1bdc7bbd..6c91ee833 100644 --- a/docs/development.md +++ b/docs/development.md @@ -95,3 +95,40 @@ $ GCM_TRACE=1 git-credential-manager-core version > 18:47:56.526712 ...er/Application.cs:69 trace: [RunInternalAsync] Git Credential Manager version 2.0.124-beta+e1ebbe1517 (macOS, .NET 5.0) 'version' > Git Credential Manager version 2.0.124-beta+e1ebbe1517 (macOS, .NET 5.0) ``` + +### Code coverage metrics + +If you want code coverage metrics these can be generated either from the command line: + +```shell +$ dotnet test --collect:"XPlat Code Coverage" --settings=./.code-coverage/coverlet.settings.xml +``` + +Or via the VSCode Terminal/Run Task: + +``` +test with coverage +``` + +HTML reports can be generated using ReportGenerator, this should be installed during the build process, from the command line: + +```shell +$ dotnet ~/.nuget/packages/reportgenerator/*/*/net5.0/ReportGenerator.dll -reports:./**/TestResults/**/coverage.cobertura.xml -targetdir:./out/code-coverage +``` +or + +```shell +$ dotnet {$env:USERPROFILE}/.nuget/packages/reportgenerator/*/*/net5.0/ReportGenerator.dll -reports:./**/TestResults/**/coverage.cobertura.xml -targetdir:./out/code-coverage +``` + +Or via VSCode Terminal/Run Task: + +``` +report coverage - nix +``` + +or + +``` +report coverage - win +``` \ No newline at end of file diff --git a/src/shared/Atlassian.Bitbucket.Tests/Atlassian.Bitbucket.Tests.csproj b/src/shared/Atlassian.Bitbucket.Tests/Atlassian.Bitbucket.Tests.csproj index c7d3c76a6..a8597e4fc 100644 --- a/src/shared/Atlassian.Bitbucket.Tests/Atlassian.Bitbucket.Tests.csproj +++ b/src/shared/Atlassian.Bitbucket.Tests/Atlassian.Bitbucket.Tests.csproj @@ -8,7 +8,12 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + diff --git a/src/shared/Core.Tests/Core.Tests.csproj b/src/shared/Core.Tests/Core.Tests.csproj index 55052595c..ac891218c 100644 --- a/src/shared/Core.Tests/Core.Tests.csproj +++ b/src/shared/Core.Tests/Core.Tests.csproj @@ -9,7 +9,12 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + diff --git a/src/shared/GitHub.Tests/GitHub.Tests.csproj b/src/shared/GitHub.Tests/GitHub.Tests.csproj index 05f016299..cff5ce92c 100644 --- a/src/shared/GitHub.Tests/GitHub.Tests.csproj +++ b/src/shared/GitHub.Tests/GitHub.Tests.csproj @@ -8,7 +8,12 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + diff --git a/src/shared/Microsoft.AzureRepos.Tests/Microsoft.AzureRepos.Tests.csproj b/src/shared/Microsoft.AzureRepos.Tests/Microsoft.AzureRepos.Tests.csproj index 0b5ecb20a..e1872e6e9 100644 --- a/src/shared/Microsoft.AzureRepos.Tests/Microsoft.AzureRepos.Tests.csproj +++ b/src/shared/Microsoft.AzureRepos.Tests/Microsoft.AzureRepos.Tests.csproj @@ -8,7 +8,12 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + diff --git a/src/shared/TestInfrastructure/TestInfrastructure.csproj b/src/shared/TestInfrastructure/TestInfrastructure.csproj index 8c8f18a54..45fc06173 100644 --- a/src/shared/TestInfrastructure/TestInfrastructure.csproj +++ b/src/shared/TestInfrastructure/TestInfrastructure.csproj @@ -10,6 +10,7 @@ +