Skip to content

Commit

Permalink
Fix code coverage analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
gathogojr committed Sep 25, 2024
1 parent 799787d commit ad2cb08
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ obj/

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

Expand Down
10 changes: 5 additions & 5 deletions buildandtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ 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.Test.OData.Tests.Client'
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\Build.Desktop\Microsoft.Test.OData.Tests.Client.csproj
Expand All @@ -64,9 +64,9 @@ steps:
version: '8.x'

- task: DotNetCoreCLI@2
displayName: 'Microsoft.OData.Core.Tests for NET 8.0'
displayName: 'Test - Microsoft.OData.Core.Tests for NET 8.0'
inputs:
command: 'test'
arguments: '--configuration $(buildConfiguration) --collect "Code coverage"'
arguments: '--configuration $(buildConfiguration) --settings $(Build.SourcesDirectory)\test.runsettings --collect "Code Coverage"'
projects: |
$(Build.SourcesDirectory)\test\FunctionalTests\Microsoft.OData.Core.Tests\Microsoft.OData.Core.Tests.Net8.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 @@ -37,6 +37,10 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.1' or '$(TargetFramework)' == 'net452'">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.2" />
</ItemGroup>

<ItemGroup>
<None Remove="Data\UntypedCollection\failedresponse.json" />
<None Remove="Data\UntypedCollection\version27.xml" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public async Task WriteMixedJsonWithLargeValues()
using (MemoryStream stream = new MemoryStream())
{
IJsonWriterAsync jsonWriter = CreateJsonWriterAsync(stream, false, Encoding.UTF8);
jsonWriter.StartObjectScopeAsync();
await jsonWriter.StartObjectScopeAsync();

await jsonWriter.WriteNameAsync("s1");
await jsonWriter.WriteValueAsync("test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.1'">
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.1' or '$(TargetFramework)' == 'net452'">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.2" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.1'">
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.1' or '$(TargetFramework)' == 'net452'">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.2" />
</ItemGroup>

Expand All @@ -64,4 +64,4 @@
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(TargetFramework)' == 'net452'">
<Exec Command="&quot;$([System.Environment]::GetFolderPath(SpecialFolder.ProgramFilesX86))\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\sn.exe&quot; /Vr $(OutputPath)\Microsoft.OData.Edm.dll" />
</Target>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.1'">
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.1' or '$(TargetFramework)' == 'net452'">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.2" />
</ItemGroup>

Expand Down
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
2 changes: 2 additions & 0 deletions test/PublicApiTests/Microsoft.OData.PublicApi.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
<EmbeddedResource Include="BaseLine\Microsoft.OData.PublicApi.netstandard1.1.bsl" />
<EmbeddedResource Include="BaseLine\Microsoft.OData.PublicApi.netstandard2.0.bsl" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<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 ad2cb08

Please sign in to comment.