Eric
Eric

Reputation: 245

Unable to use Visual Studio Code Coverage with Azure Functions

I am using Visual Studio 15.3.5 and Microsoft.NET.Sdk.Functions 1.0.6.

I can run tests fine, but when I analyze the tests with Code Coverage the assembly which contains the Azure Functions is not analyzed. It is not listed in the Code Coverage assembly list. Other assemblies are listed, only the Azure Functions assembly is omitted.

Have anyone got it working?

Upvotes: 0

Views: 710

Answers (1)

David Ebbo
David Ebbo

Reputation: 43183

The reason is that for new project types, the default <DebugType> is portable, which means that the pdb's generated would not have required info needed for CodeCoverage.

Here is how you can change this: in your .csproj, add <DebugType>full</DebugType> to the <PropertyGroup>. e.g. you should have:

<PropertyGroup>
  <TargetFramework>net461</TargetFramework>
  <DebugType>full</DebugType>
</PropertyGroup>

Or you can change this from VS:

  • go to properties on the project
  • go to the build tab, then the “Advanced…” button at the bottom
  • there’s a dropdown for Debugging Information. Setting that to “Full” updates the project with the necessary property

Upvotes: 3

Related Questions