You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+43-1Lines changed: 43 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,50 @@ Codecov C# Example
6
6
7
7
This repository serves as an **example** on how to use [Codecov Global][4] for C#.
8
8
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
+
9
26
## Usage
10
27
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
+
```
12
53
13
54
14
55
View source and learn more about [Codecov Global Uploader][4]
@@ -17,3 +58,4 @@ View source and learn more about [Codecov Global Uploader][4]
0 commit comments