Skip to content

Commit

Permalink
Merge pull request #211 from giggio/OpenCover
Browse files Browse the repository at this point in the history
Add code coverage
  • Loading branch information
giggio committed Jan 11, 2015
2 parents b023775 + 896dbb1 commit 76218cd
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,6 @@ FakesAssemblies/
# LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
ModelManifest.xml

log/
3 changes: 3 additions & 0 deletions .nuget/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="coveralls.io" version="1.1.73-beta" />
<package id="NuGet.CommandLine" version="2.8.2" />
<package id="OpenCover" version="4.5.3607-rc27" />
<package id="ReportGenerator" version="2.0.4.0" />
<package id="xunit.runners" version="2.0.0-beta5-build2785" />
</packages>
1 change: 1 addition & 0 deletions CodeCracker.CSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{051F1BE2-9A44-4B84-9DF8-6537852B7BBC}"
ProjectSection(SolutionItems) = preProject
test\CSharp\AnalyzeCoreFx.ps1 = test\CSharp\AnalyzeCoreFx.ps1
test\CSharp\RunCodeCoverage.ps1 = test\CSharp\RunCodeCoverage.ps1
runTestsCS.ps1 = runTestsCS.ps1
EndProjectSection
EndProject
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ our task board, definition of done, definition of ready, etc.
[![Nuget count](http://img.shields.io/nuget/v/codecracker.svg)](https://www.nuget.org/packages/codecracker/)
[![Nuget downloads](http://img.shields.io/nuget/dt/codecracker.svg)](https://www.nuget.org/packages/codecracker/)
[![Issues open](http://img.shields.io/github/issues/code-cracker/code-cracker.svg)](https://huboard.com/code-cracker/code-cracker)
[![Coverage Status](https://coveralls.io/repos/code-cracker/code-cracker/badge.png?branch=master)](https://coveralls.io/r/code-cracker/code-cracker?branch=master)

This is a community project, free and open source. Everyone is invited to contribute, fork, share and use the code. No money shall be charged by this
software, nor it will be. Ever.
Expand Down
6 changes: 6 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ shallow_clone: false

clone_depth: 5

environment:
COVERALLS_REPO_TOKEN:
secure: 9qsI9p9EPYyYoEetOcoQ76A7zfQRdstXY81MQFnX1Zpddtc0CrQThKAFPUba12m4

before_build:
- ps: >-
echo "set path"
Expand Down Expand Up @@ -155,6 +159,8 @@ after_test:
- ps: >-
$root = $env:APPVEYOR_BUILD_FOLDER
. "$root\test\CSharp\RunCodeCoverage.ps1"
. "$root\test\CSharp\AnalyzeCoreFx.ps1"
artifacts:
Expand Down
5 changes: 4 additions & 1 deletion test/CSharp/CodeCracker.Test/packages.config
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="codecracker.CSharp" version="1.0.0-alpha3-0270" targetFramework="net45" />
<package id="coveralls.io" version="1.1.73-beta" targetFramework="net45" />
<package id="FluentAssertions" version="3.2.1" targetFramework="net45" />
<package id="Microsoft.CodeAnalysis.Common" version="1.0.0-beta1-20141031-01" targetFramework="net45" />
<package id="Microsoft.CodeAnalysis.CSharp" version="1.0.0-beta1-20141031-01" targetFramework="net45" />
<package id="Microsoft.CodeAnalysis.CSharp.Workspaces" version="1.0.0-beta1-20141031-01" targetFramework="net45" />
<package id="Microsoft.CodeAnalysis.Workspaces.Common" version="1.0.0-beta1-20141031-01" targetFramework="net45" />
<package id="Microsoft.Composition" version="1.0.27" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.7" targetFramework="net45" />
<package id="OpenCover" version="4.5.3607-rc27" targetFramework="net45" />
<package id="ReportGenerator" version="2.0.4.0" targetFramework="net45" />
<package id="System.Collections.Immutable" version="1.1.32-beta" targetFramework="net45" />
<package id="System.Reflection.Metadata" version="1.0.17-beta" targetFramework="net45" />
<package id="xunit" version="2.0.0-beta5-build2785" targetFramework="net45" />
Expand All @@ -16,4 +19,4 @@
<package id="xunit.core" version="2.0.0-beta5-build2785" targetFramework="net45" />
<package id="xunit.runner.visualstudio" version="0.99.9-build1021" targetFramework="net45" />
<package id="xunit.runners" version="2.0.0-beta5-build2785" targetFramework="net45" />
</packages>
</packages>
48 changes: 48 additions & 0 deletions test/CSharp/RunCodeCoverage.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
$rootDir = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..")
$packagesDir = "$rootDir\packages"
$openCoverExe = "$packagesDir\OpenCover.4.5.3607-rc27\OpenCover.Console.exe"
$xunitConsoleExe = "$packagesDir\xunit.runners.2.0.0-beta5-build2785\tools\xunit.console.x86.exe"
$testDll = "CodeCracker.Test.CSharp.dll"
$testDir = "$PSScriptRoot\CodeCracker.Test\bin\Debug"
$logDir = "$rootDir\log"
$outputXml = "$logDir\CodeCoverageResults.xml"
$reportGeneratorExe = "$packagesDir\ReportGenerator.2.0.4.0\ReportGenerator.exe"
$coverageReportDir = "$logDir\codecoverage\"
$converallsNetExe = "$packagesDir\coveralls.io.1.1.73-beta\tools\coveralls.net.exe"

$allPaths = $openCoverExe, $xunitConsoleExe, $testDir, $logDir, $reportGeneratorExe

function testPath($paths) {
$notFound = @()
foreach($path in $paths) {
if ((Test-Path $path) -eq $false)
{
$notFound += $path
}
}
$notFound
}

if ((Test-Path $logDir) -eq $false)
{
Write-Host -ForegroundColor DarkBlue "Creating log directory $logDir"
mkdir $logDir | Out-Null
}

$notFoundPaths = testPath $allPaths
if ($notFoundPaths.length -ne 0) {
Write-Host -ForegroundColor DarkRed "Paths not found: "
foreach($path in $notFoundPaths) {
Write-Host -ForegroundColor DarkRed " $path"
}
return
}

Write-Host -ForegroundColor DarkBlue "Running Code Coverage"
. $openCoverExe -register:user "-target:$xunitConsoleExe" "-targetargs:$testDll -noshadow" "-filter:+[CodeCracker*]* -[CodeCracker.Test*]*" "-output:$outputXml" -coverbytest:*.Test.*.dll "-targetdir:$testDir" -log:All
Write-Host -ForegroundColor DarkBlue "Exporting code coverage report"
. $reportGeneratorExe -verbosity:Info -reports:$outputXml -targetdir:$coverageReportDir
if ($env:COVERALLS_REPO_TOKEN -ne $null) {
Write-Host -ForegroundColor DarkBlue "Uploading coverage report to Coveralls.io"
. $converallsNetExe --opencover $outputXml
}

0 comments on commit 76218cd

Please sign in to comment.