Skip to content

Example of codecov in fsharp

License

Notifications You must be signed in to change notification settings

codecov/example-fsharp

Repository files navigation

Codecov F# Example

https://codecov.io @codecov hello@codecov.io

Build status codecov FOSSA Status

Solution

Start by restoring the nuget packages and building the solution.

Generate the Coverage File

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:".\test\CodecovExample.Tests\bin\Debug\CodecovExample.Tests.dll -noshadow" -filter:"+[CodecovExample.TargetProject*]* -[CodecovExample.Tests*]*" -output:".\CodecovExample-FSharp.xml"

Then a coverage report will be generated.

.NET Core project

Issue

Uploading Report

Many options exit for uploading reports to Codecov. Three commonly used uploaders for .NET are

  1. Codecov-exe (C# source code)
  2. Bash
  3. Python

For OS X and Linux builds, the recommended uploader is bash. For windows builds, all three uploaders work, but Codecov-exe does not require any dependencies. For example, the bash uploader and python uploader would require bash or python to be installed. This may or may not be an option.

Codecov-exe

First install Codecov-exe via Nuget or Chocolatey. If we run the following in PowerShell to install it via Chocolatey

choco install codecov

and then run the following in PowerShell

.\codecov -f "CodecovExample-FSharp.xml" -t <your upload token>

the report will be uploaded.

Bash

In bash run the following to upload the report

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

Python

First installed python (if you don't have it already). A simple way to install python is Chocolatey

choco install python

Next run the following in PowerShell

pip install codecov
.\codecov -f "CodecovExample-FSharp.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 2017

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

build:
  project: CodecovExample.sln
  verbosity: minimal

test_script:
- OpenCover.Console.exe -register:user -target:"%xunit20%\xunit.console.x86.exe" -targetargs:".\test\CodecovExample.Tests\bin\Debug\CodecovExample.Tests.dll -noshadow" -filter:"+[CodecovExample.TargetProject*]* -[CodecovExample.Tests*]*" -output:".\CodecovExample-FSharp.xml"
- codecov -f "CodecovExample-FSharp.xml"

Codecov-exe using NuGet

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

image: Visual Studio 2017

before_build:
- nuget restore

build:
  project: CodecovExample.sln
  verbosity: minimal

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

Python

image: Visual Studio 2017

before_build:
- nuget restore
- choco install opencover.portable

build:
  project: CodecovExample.sln
  verbosity: minimal

test_script:
- OpenCover.Console.exe -register:user -target:"%xunit20%\xunit.console.x86.exe" -targetargs:".\test\CodecovExample.Tests\bin\Debug\CodecovExample.Tests.dll -noshadow" -filter:"+[CodecovExample.TargetProject*]* -[CodecovExample.Tests*]*" -output:".\CodecovExample-FSharp.xml"
- "SET PATH=C:\\Python34;C:\\Python34\\Scripts;%PATH%"
- pip install codecov
- codecov -f "CodecovExample-FSharp.xml"

Fake

If you use Fake (F# Make) for your build automation there is a support for OpenCover.

Cake

If you use Cake (C# Make) for your build automation, there is a Cake.Codecov addin available. Cake also has built in support for OpenCover.

We are happy to help if you have any questions. Please contact email our Support at support@codecov.io

License

FOSSA Status

About

Example of codecov in fsharp

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages