Skip to content

Commit fbe828a

Browse files
authored
Merge pull request #1 from testspace-samples/static_analysis
Added static analysis to build and publishing to Testspace
2 parents eef5ba1 + 536e3c9 commit fbe828a

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

README.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,42 @@
33

44
## C#/NUnit sample for demonstrating Testspace
55

6-
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.
6+
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).
7+
8+
***
9+
Build using AppVeyor's Online CI:
710

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

15+
[![Space Health](https://samples.testspace.com/projects/94/spaces/343/badge)](https://samples.testspace.com/projects/94/spaces/343 "Test Cases")
16+
[![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)")
17+
[![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)")
18+
[![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)")
19+
[![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)")
1420
***
1521

16-
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.
22+
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.
23+
24+
Building with static analysis:
1725

18-
Publishing results example:
26+
<pre>
27+
msbuild money/cs-money.csproj /p:runCodeAnalysis=true /p:codeanalysislogfile=StaticAnalysis.xml
28+
</pre>
29+
Running tests with code coverage:
1930

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

23-
testspace publish TestResult.xml codecoverage.xml
34+
</pre>
35+
36+
Publishing Results using **Testspace** in powershell:
37+
38+
<pre>
39+
wget https://testspace-client.s3.amazonaws.com/testspace-windows.zip -outfile .\money\packages\testspace.zip
40+
extract to preferred location
41+
testspace .\testresult.xml .\coverage.xml money\staticanalysis.xml ${ENV:TESTSPACE_TOKEN}/${ENV:BRANCH_NAME}
2442
</pre>
2543

2644
Checkout the [Space](https://samples.testspace.com/projects/csharp/spaces/nunit).

appveyor.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ install:
66
77
mkdir .\money\packages\testspace
88
9-
wget https://testspace-runner.s3.amazonaws.com/testspace-windows-latest.zip -outfile .\money\packages\testspace.zip
9+
wget https://testspace-client.s3.amazonaws.com/testspace-windows.zip -outfile .\money\packages\testspace.zip
1010
1111
7z x .\money\packages\testspace.zip -omoney\packages\testspace
12-
before_build:
13-
- cmd: nuget restore money/cs-money.sln
14-
build:
15-
project: money/cs-money.sln
16-
verbosity: minimal
12+
build_script:
13+
- ps: >-
14+
nuget restore money/cs-money.sln
15+
16+
msbuild money/cs-money.csproj /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:runCodeAnalysis=true /p:codeanalysislogfile=StaticAnalysis.xml
1717
test_script:
1818
- ps: >-
1919
.\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
2020
21-
.\money\packages\testspace\testspace.exe publish .\testresult.xml .\coverage.xml "${ENV:TESTSPACE_URL}"
21+
.\money\packages\testspace\testspace.exe publish .\testresult.xml .\coverage.xml .\money\staticanalysis.xml "${ENV:TESTSPACE_URL}"

0 commit comments

Comments
 (0)