Skip to content

Commit d934198

Browse files
committed
First draft
1 parent c534402 commit d934198

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

readme.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,50 @@ Codecov C# Example
66

77
This repository serves as an **example** on how to use [Codecov Global][4] for C#.
88

9+
## Installation
10+
11+
You need to add two nuget packages to your Visual Studio solution:
12+
13+
The first package is [OpenCover][5] which will be used to generate code coverage analysis:
14+
15+
```
16+
PM> Install-Package OpenCover
17+
```
18+
19+
The second package is ??? which will be used to upload the XML file generated by [OpenCover][5] to Codecov.io:
20+
21+
```
22+
PM> Install-Package ???
23+
```
24+
25+
926
## Usage
1027

11-
> coming soon. Thanks!
28+
Let's assume your C# solution has the following folder structure:
29+
30+
- C:\_build\MyProject\ --> this is your solution's root folder. For instance, this is where you have saved your visual studio solution (.sln) file.
31+
- C:\_build\MyProject\packages\ --> this is where all nuget packages are downloaded
32+
- C:\_build\MyProject\MyProject Unit Tests\ --> this is where your C# unit testing project is located (.csproj)
33+
34+
To generate code coverage analysis, execute the following comment from a command prompt in your solution's root:
35+
36+
```
37+
.\packages\OpenCover.4.5.3522\OpenCover.Console.exe -register:user -target:"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\MSTest.exe" -targetargs:"/noresults /noisolation /testcontainer:"".\MyProject Unit Tests\bin\Debug\MyProject.UnitTests.dll" -filter:"+[MyProject]* -[MyProject]MyProject.Properties.*" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -output:.\MyProject_coverage.xml
38+
```
39+
40+
This command makes a few assumptions which you will most likely have to adjust to meet your needs:
41+
42+
1. Use OpenCover v4.5.3522, which is the latest version as of this writing, to generate code coverage. Of course you will need to adjust the path to the OpenCover package when new versions are available.
43+
2. Unit tests are compiled in a DLL called .\MyProject Unit Tests\bin\Debug\MyProject.UnitTests.dll (replace 'Debug' with 'Release if you compile in 'Release' mode).
44+
3. Code coverage will include all classes, methods and properties under the [MyProject] namespace except [MyProject]MyProject.Properties. These properties, typically, include your project version number, compiler options, etc. and therefore should be excluded from the code coverage report.
45+
4. Any class decorated with the 'ExcludeFromCodeCoverage' attribute is automatically excluded from the coverage analysis.
46+
5. Code coverage analysis is written to a XML file called MyProject_coverage.xml
47+
48+
Now that you have generated your code coverage analysis, you must upload it to CodeCov. Here's the command to do so:
49+
50+
```
51+
???
52+
```
1253

1354

1455
View source and learn more about [Codecov Global Uploader][4]
@@ -17,3 +58,4 @@ View source and learn more about [Codecov Global Uploader][4]
1758
[2]: https://twitter.com/codecov
1859
[3]: mailto:hello@codecov.io
1960
[4]: https://github.com/codecov/codecov-bash
61+
[5]: https://www.nuget.org/packages/OpenCover/

0 commit comments

Comments
 (0)