Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,42 @@

## C#/NUnit sample for demonstrating Testspace

This is a sample for the use of the [NUnit](http://nunit.org/) test framework using C# [examples](https://github.com/nunit/nunit-csharp-samples). It is used to demonstrate Testspace usage models for easier test content management.
This sample demonstrates techniques for using Testspace with C# code and the [NUnit](http://nunit.org/) test framework, along with the [OpenCover](https://github.com/OpenCover/opencover) coverage tool and [Visual Studio's](https://msdn.microsoft.com/en-us/library/dd264939.aspx) static analysis tool using [NUnit's C# examples](https://github.com/nunit/nunit-csharp-samples).

***
Build using AppVeyor's Online CI:

[![Build status](https://ci.appveyor.com/api/projects/status/x76ee4x2hc84l55a?svg=true)](https://ci.appveyor.com/project/jeffs-s2/csharp-nunit)
[![Space Health](https://samples.testspace.com/projects/94/spaces/343/badge)](https://samples.testspace.com/projects/94/spaces/343 "Test Cases")
[![Space Metric](https://samples.testspace.com/projects/94/spaces/343/metrics/287/badge)](https://samples.testspace.com/spaces/343/schema/coverage "Branch/Condition Coverage")
[![Space Metric](https://samples.testspace.com/projects/94/spaces/343/metrics/289/badge)](https://samples.testspace.com/spaces/343/schema/coverage "Function/Method Coverage")
[![Space Metric](https://samples.testspace.com/projects/94/spaces/343/metrics/288/badge)](https://samples.testspace.com/spaces/343/schema/coverage "Line/Statement Coverage")
***
Publishing **Test Content** using www.testspace.com.

[![Space Health](https://samples.testspace.com/projects/94/spaces/343/badge)](https://samples.testspace.com/projects/94/spaces/343 "Test Cases")
[![Space Metric](https://samples.testspace.com/projects/94/spaces/343/metrics/217/badge)](https://samples.testspace.com/spaces/343/schema/Code%20Coverage "Code Coverage (branches)")
[![Space Metric](https://samples.testspace.com/projects/94/spaces/343/metrics/218/badge)](https://samples.testspace.com/spaces/343/schema/Code%20Coverage "Code Coverage (methods)")
[![Space Metric](https://samples.testspace.com/projects/94/spaces/343/metrics/219/badge)](https://samples.testspace.com/spaces/343/schema/Code%20Coverage "Code Coverage (sequences)")
[![Space Metric](https://samples.testspace.com/projects/94/spaces/343/metrics/220/badge)](https://samples.testspace.com/spaces/343/schema/Static%20Analysis "Static Analysis (issues)")
***

We have made a few minor modifications to to original samples for reporting purposes. In order to run this sample you will need a host workstation with Visual Studio, the [Nunit](http://nunit.org/) test framework and the [OpenCover](https://github.com/OpenCover/opencover) coverage tool.
In order to run this sample you will need a host workstation with Visual Studio, the [Nunit](http://nunit.org/) test framework and the [OpenCover](https://github.com/OpenCover/opencover) coverage tool.

Building with static analysis:

Publishing results example:
<pre>
msbuild money/cs-money.csproj /p:runCodeAnalysis=true /p:codeanalysislogfile=StaticAnalysis.xml
</pre>
Running tests with code coverage:

<pre>
OpenCover.Console.exe -target:nunit3-console.exe -targetargs:cs-money.dll -output:codecoverage.xml -register:user

testspace publish TestResult.xml codecoverage.xml
</pre>

Publishing Results using **Testspace** in powershell:

<pre>
wget https://testspace-client.s3.amazonaws.com/testspace-windows.zip -outfile .\money\packages\testspace.zip
extract to preferred location
testspace .\testresult.xml .\coverage.xml money\staticanalysis.xml ${ENV:TESTSPACE_TOKEN}/${ENV:BRANCH_NAME}
</pre>

Checkout the [Space](https://samples.testspace.com/projects/csharp/spaces/nunit).
Expand Down
14 changes: 7 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ install:

mkdir .\money\packages\testspace

wget https://testspace-runner.s3.amazonaws.com/testspace-windows-latest.zip -outfile .\money\packages\testspace.zip
wget https://testspace-client.s3.amazonaws.com/testspace-windows.zip -outfile .\money\packages\testspace.zip

7z x .\money\packages\testspace.zip -omoney\packages\testspace
before_build:
- cmd: nuget restore money/cs-money.sln
build:
project: money/cs-money.sln
verbosity: minimal
build_script:
- ps: >-
nuget restore money/cs-money.sln

msbuild money/cs-money.csproj /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:runCodeAnalysis=true /p:codeanalysislogfile=StaticAnalysis.xml
test_script:
- ps: >-
.\money\packages\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:".\money\packages\NUnit.ConsoleRunner.3.2.1\tools\nunit3-console.exe" -targetargs:'.\money\bin\Debug\cs-money.dll' -output:'.\coverage.xml' -filter:'+[*]* -[*]*MoneyTest*' -register:user

.\money\packages\testspace\testspace.exe publish .\testresult.xml .\coverage.xml "${ENV:TESTSPACE_URL}"
.\money\packages\testspace\testspace.exe publish .\testresult.xml .\coverage.xml .\money\staticanalysis.xml "${ENV:TESTSPACE_URL}"