Skip to content

Commit

Permalink
Fix code coverage analysis (#3074)
Browse files Browse the repository at this point in the history
  • Loading branch information
gathogojr authored Oct 1, 2024
1 parent 5dca48f commit 3c5c6c9
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ obj/
*.vspscc

# Test results
sln/TestResults/
**/TestResults/
test/packages/
*BenchmarkDotNet.Artifacts*

Expand Down
6 changes: 3 additions & 3 deletions buildandtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
57 changes: 57 additions & 0 deletions test.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
</RunConfiguration>
<!-- Configurations for data collectors -->
<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>
<CodeCoverage>
<ModulePaths>
<Include>
<ModulePath>.*Microsoft\.OData\.Core\.dll$</ModulePath>
<ModulePath>.*Microsoft\.OData\.Edm\.dll$</ModulePath>
<ModulePath>.*Microsoft\.OData\.Client\.dll$</ModulePath>
<ModulePath>.*Microsoft\.Spatial\.dll$</ModulePath>
</Include>
<Exclude>
<ModulePath>.*CPPUnitTestFramework.*</ModulePath>
</Exclude>
</ModulePaths>
<!-- Match attributes on any code element: -->
<!-- https://docs.microsoft.com/en-us/visualstudio/test/customizing-code-coverage-analysis?#sample-runsettings-file -->
<Attributes>
<Exclude>
<!-- Don't forget "Attribute" at the end of the name -->
<Attribute>^System\.Diagnostics\.DebuggerHiddenAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.DebuggerNonUserCodeAttribute$</Attribute>
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
</Exclude>
</Attributes>
<!-- We recommend you do not change the following values: -->
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<CollectAspDotNet>False</CollectAspDotNet>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<!-- Parameters used by tests at runtime -->
<TestRunParameters>
</TestRunParameters>
<!-- Adapter Specific sections -->
<!-- MSTest adapter -->
<MSTest>
<!--<SettingsFile>test.testsettings</SettingsFile>-->
<InProcMode>false</InProcMode>
<ForcedLegacyMode>false</ForcedLegacyMode>
<MapInconclusiveToFailed>false</MapInconclusiveToFailed>
<CaptureTraceOutput>false</CaptureTraceOutput>
<DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
</MSTest>
</RunSettings>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PackageReference Include="FluentAssertions" Version="4.1.0" />
<PackageReference Include="EntityFramework" Version="5.0.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Microsoft.VisualStudio.TextTemplating.Interfaces.10.0" Version="10.0.30320" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public void CallingDeepInsertRequest_WithNullArguments_ShouldThrowAnException()
[Fact]
public async Task CallingDeepInsertAsyncRequest_WithUntrackedEntity_ShouldThrowAnInvalidException()
{
Assert.Throws<InvalidOperationException>(delegate { this.context.DeepInsertAsync<Person>(this.person); });
await Assert.ThrowsAsync<InvalidOperationException>(() => this.context.DeepInsertAsync<Person>(this.person));
}

[Fact]
Expand Down
1 change: 1 addition & 0 deletions test/PublicApiTests/Microsoft.OData.PublicApi.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.0" />
</ItemGroup>

</Project>

0 comments on commit 3c5c6c9

Please sign in to comment.