• Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    C#
  • License
    MIT License
  • Created over 9 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Codecov: C# example repository

Codecov C# Example

codecov AppVeyor FOSSA Status

Guide

AppVeyor Setup

Add to your appveyor.yml file.

image: Visual Studio 2015

before_build:
- nuget restore
- choco install opencover.portable
- choco install codecov

build:
  project: CodecovProject.sln
  verbosity: minimal

test_script:
- OpenCover.Console.exe -register:user -target:"%xunit20%\xunit.console.x86.exe" -targetargs:".\MyUnitTests\bin\Debug\MyUnitTests.dll -noshadow" -filter:"+[UnitTestTargetProject*]* -[MyUnitTests*]*" -output:".\MyProject_coverage.xml"
- codecov -f "MyProject_coverage.xml

Producing Coverage Reports

Coverage is generated using OpenCover. You can obtain it from NuGet or Chocolatey. If we run the following command in PowerShell to install OpenCover via Chocolatey,

choco install opencover.portable

the OpenCover commandline will become available.

Generation of coverage report is slighly different depending on the .NET platform of your test projects.

.NET Framework project

xUnit

First install the xUnit console runner via Nuget or Chocolatey. If we run the following in PowerShell to install xUnit via Chocolatey

choco install xunit

and execute the following in your solution's root,

OpenCover.Console.exe -register:user -target:"xunit.console.x86.exe" -targetargs:".\MyUnitTests\bin\Debug\MyUnitTests.dll -noshadow" -filter:"+[UnitTestTargetProject*]* -[MyUnitTests*]*" -output:".\MyProject_coverage.xml"

Then a coverage report will be generated.

MSTest

Execute the following in your solution's root,

OpenCover.Console.exe -register:user -target:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\MSTest.exe" -targetargs:"/testcontainer:"".\MyUnitTests\bin\Debug\MyUnitTests.dll" -filter:"+[UnitTestTargetProject*]* -[MyUnitTests*]*" -output:".\MyProject_coverage.xml"

where you may need to change the -target flag to point to the correct version of MSTest.

.NET Core project

If you don't yet have .NET Core SDK installed, install it

choco install dotnetcore-sdk

In case of .NET Core projects, there is no difference between MSTest and xUnit for coverage report generation.

Make sure all covered projects generate full pdb file (not only test projects), either through <DebugType>full</DebugType> in the .csproj file or by using a Visual Studio: Project Properties > Build > Advanced > Debugging information. By default, projects created by dotnet or by Visual Studio use a portable format for pdb files. Support for portable pdb format hasn't been released in OpenCover yet. If you fail to set full pdb, the OpenCover will print out a message notifying you that it has no results along with common causes.

The .NET Core test assembly can't be run by a xunit.console.x86.exe, because that tool works only with .NET Framework assemblies. The tests are run by dotnet test (possibly dotnet xunit if you add dotnet-xunit CLI tool to your project).

Execute the following command in your solution's root:

OpenCover.Console.exe -register:user -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:test -filter:"+[UnitTestTargetProject*]* -[MyUnitTests*]*" -output:".\MyProject_coverage.xml" -oldstyle

where -oldstyle switch is necessary, because .NET Core uses System.Private.CoreLib instead of mscorlib and thus OpenCover can't use mscorlib for code instrumentation. You may also need to change the location of dotnet.exe to depending on the installed location.

Bash

In bash run the following to upload the report

curl -s https://codecov.io/bash > codecov
chmod +x codecov
./codecov -f "MyProject_coverage.xml" -t <your upload token>

Continous Integration

The previous examples assumed local development. More commonly, you'll use a CI service like AppVeyor or TeamCity. For TeamCity builds please see the documentation. For AppVeyor builds using xUnit, your yaml file would look something like

Codecov-exe using Chocolatey

image: Visual Studio 2015

before_build:
- nuget restore
- choco install opencover.portable
- choco install codecov

build:
  project: CodecovProject.sln
  verbosity: minimal

test_script:
- OpenCover.Console.exe -register:user -target:"%xunit20%\xunit.console.x86.exe" -targetargs:".\MyUnitTests\bin\Debug\MyUnitTests.dll -noshadow" -filter:"+[UnitTestTargetProject*]* -[MyUnitTests*]*" -output:".\MyProject_coverage.xml"
- codecov -f "MyProject_coverage.xml"

Codecov-exe using NuGet

Using this method you can cache your packages.config file.

image: Visual Studio 2015

before_build:
- nuget restore

build:
  project: CodecovProject.sln
  verbosity: minimal

test_script:
- .\packages\<ADD PATH>\OpenCover.Console.exe -register:user -target:"%xunit20%\xunit.console.x86.exe" -targetargs:".\MyUnitTests\bin\Debug\MyUnitTests.dll -noshadow" -filter:"+[UnitTestTargetProject*]* -[MyUnitTests*]*" -output:".\MyProject_coverage.xml"
- .\packages\<ADD PATH>\codecov.exe -f "MyProject_coverage.xml"

Caveats

Private Repo

Repository tokens are required for (a) all private repos, (b) public repos not using Travis-CI, CircleCI, GitHub Actions, or AppVeyor. Find your repository token at Codecov and provide via appending -t <your upload token> to you where you upload reports e.g. .\codecov -f "MyProject_coverage.xml" -t <your upload token>

Links

License

FOSSA Status

More Repositories

1

codecov-action

GitHub Action that uploads coverage to Codecov ☂️
TypeScript
1,469
star
2

self-hosted

Example of how to setup Codecov with docker compose
Shell
424
star
3

example-python

Python coverage example
Python
301
star
4

codecov-node

Global coverage report uploader for Codecov in NodeJS
JavaScript
292
star
5

codecov-bash

Global coverage report uploader for Codecov
Shell
233
star
6

browser-extension

Codecov Browser Extension
JavaScript
213
star
7

codecov-api

Code for the API of Codecov
Python
213
star
8

example-go

Go coverage example
Go
213
star
9

example-node

Example repo for uploading reports to Codecov
JavaScript
192
star
10

codecov-python

Python report uploader for Codecov
Python
184
star
11

example-android

Android code coverage example with https://codecov.io
Java
145
star
12

example-cpp11-cmake

CMake
144
star
13

example-swift

Codecov: Swift coverage example
Swift
127
star
14

uploader

Codecov's universal binary uploader.
TypeScript
104
star
15

timestring

Making time easier since "Jan 17th, 2013 at 3:59pm"
Python
101
star
16

example-rust

Rust
89
star
17

example-php

PHP coverage example
PHP
88
star
18

example-java-gradle

Java
86
star
19

sourcegraph-codecov

See code coverage information from Codecov on GitHub, Sourcegraph, and other tools.
TypeScript
74
star
20

codecov-ruby

Ruby uploader for Codecov
Ruby
72
star
21

example-java

Java Example
70
star
22

example-java-maven

Java
58
star
23

example-bash

Codecov: Bash/Shell coverage example
Ruby
50
star
24

codecov-cli

Codecov's Command Line Interface. Used for uploading to Codecov in your CI, Test Labelling, Local Upload, and more
Python
50
star
25

worker

Code for Background Workers of Codecov
Python
47
star
26

example-typescript

Example repo for uploading reports to Codecov https://codecov.io
TypeScript
47
star
27

gazebo

React SPA
TypeScript
45
star
28

example-c

Upload reports to Codecov using C/C++
C
35
star
29

example-scala

Scala coverage example
Scala
35
star
30

codecov-browser-extension

A browser extension for Codecov. Works for Chrome and Firefox
TypeScript
35
star
31

feedback

A place to discuss feedback about the pull request and web product experience.
34
star
32

opentelem-laravel

A WIP exporter for Laravel to capture and export opentelem data.
PHP
33
star
33

dart

Codecov Dart coverage report uploader
Dart
29
star
34

example-objc

Codecov example for Xcode
Objective-C
26
star
35

codecov-exe

.exe report uploader for Codecov https://codecov.io
C#
25
star
36

example-perl

Perl
23
star
37

example-fortran

Example repo for uploading reports to Codecov
Fortran
22
star
38

codecov-circleci-orb

Python
20
star
39

example-ruby

Ruby coverage example
Ruby
20
star
40

swift-standard

Codecov coverage standard for Swift
Swift
19
star
41

example-kotlin

Kotlin coverage example
Kotlin
19
star
42

example-r

R
17
star
43

example-elixir

Elixir
16
star
44

go-standard

Codecov coverage standard for go
Python
14
star
45

codecov-perl

Backend for Codecov reporting of coverage
Perl
14
star
46

contributing

14
star
47

example-clojure

Example Clojure integration with Codecov
Clojure
14
star
48

python-standard

Codecov coverage standard for Python
Python
14
star
49

shared

Shared code between worker and api
Python
13
star
50

example-vala

Vala
12
star
51

cf-flags-demo

A demo of Codecov's carryforward flags feature.
Python
12
star
52

example-julia

Julia
11
star
53

example-d

Example repository for D and Codecov
D
10
star
54

kotlin-standard

Codecov coverage standard for Kotlin
Kotlin
9
star
55

typescript-standard

Codecov coverage standard for TypeScript
JavaScript
9
star
56

java-standard

Codecov coverage standard for Java
Python
9
star
57

standards

List of Codecov language standards
C++
8
star
58

example-groovy

Groovy coverage example
Groovy
7
star
59

example-lua

Shell
7
star
60

vscode

A Codecov vscode extention which helps validate and configure new repositories.
Python
7
star
61

cpp-11-standard

Codecov coverage standard for c++ 11
C++
6
star
62

helm-charts

Public Helm Charts
6
star
63

example-fsharp

Example of codecov in fsharp
F#
6
star
64

example-actions-bundled

Python
5
star
65

codecov-demo-full

JavaScript
5
star
66

codecov-racket

Codecov support for Cover.
Racket
5
star
67

opentelem-node

A WIP OpenTelemetry Exporter for Runtime Insights
JavaScript
4
star
68

example-erlang

Erlang
4
star
69

example-cpp

4
star
70

nginx

Dockerfile
4
star
71

test-results-action

TypeScript
4
star
72

codecov-javascript-bundler-plugins

Set of bundler plugins that allow users to upload bundle stats to Codecov.
TypeScript
4
star
73

media

Press and marketing resources
3
star
74

example-xtend

Xtend coverage example
Xtend
3
star
75

example-scala-maven

Scala via Maven coverage example
Scala
3
star
76

codecov-ats

GitHub Action that uploads returns selected test labels to CI ☂️
Shell
3
star
77

ruby-standard-2

Codecov coverage standard for Ruby using Codecov's Bash uploader
Ruby
3
star
78

example-haskell

3
star
79

example-delphi

2
star
80

ruby-standard-1

Codecov coverage standard for Ruby using the Codecov gem
Ruby
2
star
81

example-csharp-sharpcover

C#
2
star
82

example-azure-pipelines

Azure Pipelines coverage example
Python
2
star
83

example-kotlin-flat

Kotlin codecov example with standard file structure
Kotlin
2
star
84

opentelem-python

Open Telemetry Python Prototype
Python
2
star
85

enterprise-rhe

Shell
2
star
86

codecov-slack-app

Python
2
star
87

codecov-bitrise

Shell
1
star
88

node-static-alpine

Internal Node builder for the Alpine version of the uploader
1
star
89

example-java-ant

1
star
90

impact-analysis-example-laravel

An example repository demonstrating runtime insights with Laravel
PHP
1
star
91

example-gradle-multiproject

Java
1
star
92

xcode-poc

Swift
1
star
93

ci-repo

debug and ci only
Python
1
star
94

prometheus

Shell
1
star
95

example-javascript

JavaScript
1
star
96

.github

Community Health Files for the Codecov Organization
1
star
97

engineering-team

This is a general repo to use with GH Projects
1
star
98

grafana

Dockerfile
1
star
99

node-alpine-static

Builds a fully static copy of NodeJS from source to be used by codecov/uploader
1
star
100

codecov-interview-api

Python
1
star