Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Code Coverage doesn't include projects not referenced by Tests Projects

Aperta
#14 2 commenti 1 reazione 1 assegnatario Vedi su GitHub

@jakubch1 ci sta già lavorando.

Dal 7/3/2023.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

enhancement

Description

I noticed that projects which are not referenced by Tests projects are not included in the Coverage results, is there are way to get them included? It's important to include them because that does change overall percentage.

I'm creating this since https://stackoverflow.com/questions/42013013/analyze-code-coverage-with-visual-studio-skips-some-projects has not been answered, so hopefully you can help.

I've tried many different configurations in my .runnsettings, including a recursive ModulePaths/IncludeDirectories and specifically including the missing DLL.

I've been reading the docs but didn't find any settings which could make it, did I miss anything?

Thanks!

Steps to reproduce

Solution.sln (C:\source)
ProjectA
ProjectB
TestProject
References ProjectA only

coverage.runsettings:

<RunSettings>
  <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>
            <Sources>
	      <Include>
	        <Source>C:\\source\\.*</Source>
	      </Include>
            </Sources>
            <UseVerifiableInstrumentation>False</UseVerifiableInstrumentation>
            <AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
            <CollectFromChildProcesses>True</CollectFromChildProcesses>
            <CollectAspDotNet>False</CollectAspDotNet>
          </CodeCoverage>
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
  <RunConfiguration>
    <MaxCpuCount>0</MaxCpuCount>
    <BatchSize>1000</BatchSize>
    <ResultsDirectory>C:\results</ResultsDirectory>
  </RunConfiguration>
</RunSettings>

Once solution is built, I can see all DLLs and PDBs in their own files, and in TestsProject bin's folder only ProjectA.dll/pdb is there as expected.

Then run vstest

vstest.console.exe "C:\sources\TestProject\bin\release\TestProject.dll" /Settings:"C:\coverage.runsettings" /Logger:"trx" /TestAdapterPath:"c:\Source"

(don't think Logger and TestAdapterPath are important but that is how I've been running)

Expected behavior

.coverage included ProjectB on it, stating 0 covered blocks as that will for sure change the overall percentage

Actual behavior

ProjectB is not included, only ProjectA and TestProjects are present .

Diagnostic logs

I don't have a diag I can share now as I'm building some real projects, if really needed I can create a test solution and do it.

Environment

Microsoft (R) Test Execution Command Line Tool Version 17.0.0

Lingua principale
C#
Stelle
125
Fork
17
Merge medio
1h 17m
PR unite (30g)
2

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/codecoverage

Tutte le issue di microsoft/codecoverage

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.