From 3c5c6c9c860303173871167ba2fbe69f3302b8fd Mon Sep 17 00:00:00 2001 From: John Gathogo Date: Tue, 1 Oct 2024 14:35:54 +0300 Subject: [PATCH] Fix code coverage analysis (#3074) --- .gitignore | 2 +- buildandtest.yml | 6 +- test.runsettings | 57 +++++++++++++++++++ ...icrosoft.Test.OData.PluggableFormat.csproj | 2 +- .../Tests/DeepInsertE2ETests.cs | 2 +- .../Microsoft.OData.PublicApi.Tests.csproj | 1 + 6 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 test.runsettings diff --git a/.gitignore b/.gitignore index 9adba68fb4..c95bfafac8 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,7 @@ obj/ *.vspscc # Test results -sln/TestResults/ +**/TestResults/ test/packages/ *BenchmarkDotNet.Artifacts* diff --git a/buildandtest.yml b/buildandtest.yml index 976e497b3f..247ff14625 100644 --- a/buildandtest.yml +++ b/buildandtest.yml @@ -32,15 +32,15 @@ steps: displayName: 'Test' inputs: command: 'test' - arguments: '--configuration $(BuildConfiguration) --no-build --collect "Code coverage"' + arguments: '--configuration $(buildConfiguration) --settings $(Build.SourcesDirectory)\test.runsettings --no-build --collect "Code Coverage"' projects: | $(Build.SourcesDirectory)\sln\OData.Pipeline.sln - task: DotNetCoreCLI@2 condition: eq(variables.buildConfiguration, 'Release') - displayName: 'Test' + displayName: 'Test - Microsoft.OData.Client.E2E.Tests' inputs: command: 'test' - arguments: '--configuration $(buildConfiguration) --collect "Code coverage"' + arguments: '--configuration $(buildConfiguration) --settings $(Build.SourcesDirectory)\test.runsettings --collect "Code Coverage"' projects: | $(Build.SourcesDirectory)\test\EndToEndTests\Tests\Client\Microsoft.OData.Client.E2E.Tests\Microsoft.OData.Client.E2E.Tests.csproj diff --git a/test.runsettings b/test.runsettings new file mode 100644 index 0000000000..48ea0c33e4 --- /dev/null +++ b/test.runsettings @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + .*Microsoft\.OData\.Core\.dll$ + .*Microsoft\.OData\.Edm\.dll$ + .*Microsoft\.OData\.Client\.dll$ + .*Microsoft\.Spatial\.dll$ + + + .*CPPUnitTestFramework.* + + + + + + + + ^System\.Diagnostics\.DebuggerHiddenAttribute$ + ^System\.Diagnostics\.DebuggerNonUserCodeAttribute$ + ^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$ + ^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$ + + + + True + True + True + False + + + + + + + + + + + + + false + false + false + false + False + + \ No newline at end of file diff --git a/test/FunctionalTests/Tests/DataOData/Tests/OData.PluggableFormat/Microsoft.Test.OData.PluggableFormat.csproj b/test/FunctionalTests/Tests/DataOData/Tests/OData.PluggableFormat/Microsoft.Test.OData.PluggableFormat.csproj index d8560b1a16..a5b4515bf9 100644 --- a/test/FunctionalTests/Tests/DataOData/Tests/OData.PluggableFormat/Microsoft.Test.OData.PluggableFormat.csproj +++ b/test/FunctionalTests/Tests/DataOData/Tests/OData.PluggableFormat/Microsoft.Test.OData.PluggableFormat.csproj @@ -27,7 +27,7 @@ - + diff --git a/test/FunctionalTests/Tests/DataServices/UnitTests/Client.TDD.Tests/Tests/DeepInsertE2ETests.cs b/test/FunctionalTests/Tests/DataServices/UnitTests/Client.TDD.Tests/Tests/DeepInsertE2ETests.cs index e8d47a9338..9cdc837e7b 100644 --- a/test/FunctionalTests/Tests/DataServices/UnitTests/Client.TDD.Tests/Tests/DeepInsertE2ETests.cs +++ b/test/FunctionalTests/Tests/DataServices/UnitTests/Client.TDD.Tests/Tests/DeepInsertE2ETests.cs @@ -202,7 +202,7 @@ public void CallingDeepInsertRequest_WithNullArguments_ShouldThrowAnException() [Fact] public async Task CallingDeepInsertAsyncRequest_WithUntrackedEntity_ShouldThrowAnInvalidException() { - Assert.Throws(delegate { this.context.DeepInsertAsync(this.person); }); + await Assert.ThrowsAsync(() => this.context.DeepInsertAsync(this.person)); } [Fact] diff --git a/test/PublicApiTests/Microsoft.OData.PublicApi.Tests.csproj b/test/PublicApiTests/Microsoft.OData.PublicApi.Tests.csproj index 1c509b7aef..026b8c2bb2 100644 --- a/test/PublicApiTests/Microsoft.OData.PublicApi.Tests.csproj +++ b/test/PublicApiTests/Microsoft.OData.PublicApi.Tests.csproj @@ -27,6 +27,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + \ No newline at end of file