Skip to content

Commit

Permalink
Issue 5 (#7)
Browse files Browse the repository at this point in the history
* added XSLT transform (from here: https://github.com/nunit/nunit-transforms ). Now tests are uploaded in Junit format.

* Upgrade Nunit version. include info page viewd on TFS Extension page.
  • Loading branch information
RobertK66 authored Jul 2, 2016
1 parent cb91f3c commit 31bf7b2
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 18 deletions.
3 changes: 2 additions & 1 deletion TFSExtension/BuildResultsEnhancer/src/enhancer/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ export class StatusSection extends Controls.BaseControl {

public initialize(): void {
super.initialize();




// Get configuration that's shared between extension and the extension host
var sharedConfig: TFS_Build_Extension_Contracts.IBuildResultsViewExtensionConfig = VSS.getConfiguration();

Expand Down
11 changes: 7 additions & 4 deletions TFSExtension/RunNunitWithOpenCover/RunOpenCover.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ param (
)

$ocToolPath = "dist\OpenCover.4.6.519\tools"
$nuToolPath = "dist\NUnit.ConsoleRunner.3.2.1\tools"
$nuToolPath = "dist\NUnit.ConsoleRunner.3.4.1\tools"
$rgToolPath = "dist\ReportGenerator.2.4.5.0\tools"
$restHelperPath = "dist\RestHelper"

Expand Down Expand Up @@ -65,7 +65,7 @@ $nunitproject = $nunitproject + "

$cmd = ".\${ocToolPath}\OpenCover.Console.exe"
$arg1 = "-target:"".\$nuToolPath\nunit3-console.exe"""
$arg2 = "-targetargs:""$filelist --work=$outputPath"""
$arg2 = "-targetargs:""$filelist --work=$outputPath --result=junit-results.xml;transform=.\dist\nunit3-junit.xslt"""
$arg3 = "-filter:""$coverageFilter"""
$arg4 = "-register:$registerOption"
$arg5 = "-coverbytest:*"
Expand All @@ -85,9 +85,12 @@ if ($generateReport -eq "true") {

Publish-BuildArtifact "OpenCoverResult" $outputPath

$exampleResult = Resolve-Path ".\dist\ResultDummy.xml"
#the result file (from XSLT in Nunit call) is not UTF8 encoded :-( -> we have to do this here in en extra step!
Get-Content $outputPath\junit-results.xml | Set-Content -Encoding utf8 $outputPath\junit-results-utf8.xml

$testResult = Resolve-Path "$outputPath\junit-results-utf8.xml"
$RunTitle = "OpenCover_TestRun_$env:BUILD_BUILDNUMBER"
Publish-TestResults -TestRunner "NUnit" -TestResultsFiles $exampleResult -MergeResults $true -Context $distributedTaskContext -PublishRunLevelAttachments $true -RunTitle $RunTitle
Publish-TestResults -TestRunner "JUnit" -TestResultsFiles $testResult -MergeResults $true -Context $distributedTaskContext -PublishRunLevelAttachments $true -RunTitle $RunTitle

$cmd = ".\${restHelperPath}\TFSRestTool.exe"
$arg1 = "$env:SYSTEM_TEAMFOUNDATIONSERVERURI$env:SYSTEM_TEAMPROJECTID/"
Expand Down
66 changes: 66 additions & 0 deletions TFSExtension/RunNunitWithOpenCover/nunit3-junit.xslt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/test-run">
<testsuites tests="{@testcasecount}" failures="{@failed}" disabled="{@skipped}" time="{@duration}">
<xsl:apply-templates/>
</testsuites>
</xsl:template>

<xsl:template match="test-suite">
<xsl:if test="test-case">
<testsuite tests="{@testcasecount}" time="{@duration}" errors="{@testcasecount - @passed - @skipped - @failed}" failures="{@failed}" skipped="{@skipped}" timestamp="{@start-time}">
<xsl:attribute name="name">
<xsl:for-each select="ancestor-or-self::test-suite/@name">
<xsl:value-of select="concat(., '.')"/>
</xsl:for-each>
</xsl:attribute>
<xsl:apply-templates select="test-case"/>
</testsuite>
<xsl:apply-templates select="test-suite"/>
</xsl:if>
<xsl:if test="not(test-case)">
<xsl:apply-templates/>
</xsl:if>
</xsl:template>

<xsl:template match="test-case">
<testcase name="{@name}" assertions="{@asserts}" time="{@duration}" status="{@result}" classname="{@classname}">
<xsl:if test="@runstate = 'Skipped' or @runstate = 'Ignored'">
<skipped/>
</xsl:if>

<xsl:apply-templates/>
</testcase>
</xsl:template>

<xsl:template match="command-line"/>
<xsl:template match="settings"/>

<xsl:template match="output">
<system-out>
<xsl:value-of select="output"/>
</system-out>
</xsl:template>

<xsl:template match="stack-trace">
</xsl:template>

<xsl:template match="test-case/failure">
<failure message="{./message}">
<xsl:value-of select="./stack-trace"/>
</failure>
</xsl:template>

<xsl:template match="test-suite/failure"/>

<xsl:template match="test-case/reason">
<skipped message="{./message}"/>
</xsl:template>

<xsl:template match="test-suite/reason"/>

<xsl:template match="properties"/>
</xsl:stylesheet>

2 changes: 1 addition & 1 deletion TFSExtension/RunNunitWithOpenCover/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 0,
"Minor": 0,
"Patch": 3
"Patch": 4
},
"demands": [
"Cmd"
Expand Down
4 changes: 3 additions & 1 deletion TFSExtension/TFSExtension.sln
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TFSRestTool", "TFSRestTool\TFSRestTool.csproj", "{783DCCBC-8A8B-4A47-9CB6-6317DC1676CD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6AB4E37D-4913-4E35-975F-847E29340BC4}"
ProjectSection(SolutionItems) = preProject
build.bat = build.bat
clean.bat = clean.bat
details.md = details.md
extension-icon128.png = extension-icon128.png
..\README.md = ..\README.md
vss-extension.json = vss-extension.json
Expand All @@ -18,6 +19,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RunNunitWithOpenCover", "RunNunitWithOpenCover", "{1BC2C287-01A6-41D4-88D9-8D9049047ADC}"
ProjectSection(SolutionItems) = preProject
RunNunitWithOpenCover\icon.png = RunNunitWithOpenCover\icon.png
RunNunitWithOpenCover\nunit3-junit.xslt = RunNunitWithOpenCover\nunit3-junit.xslt
RunNunitWithOpenCover\ResultDummy.xml = RunNunitWithOpenCover\ResultDummy.xml
RunNunitWithOpenCover\RunOpenCover.ps1 = RunNunitWithOpenCover\RunOpenCover.ps1
RunNunitWithOpenCover\task.json = RunNunitWithOpenCover\task.json
Expand Down
13 changes: 7 additions & 6 deletions TFSExtension/TFSRestTool/packages.config
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit.ConsoleRunner" version="3.2.1" targetFramework="net461" />
<package id="NUnit.Extension.NUnitProjectLoader" version="3.2.1" targetFramework="net461" />
<package id="NUnit.Extension.NUnitV2Driver" version="3.2.1" targetFramework="net461" />
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.2.1" targetFramework="net461" />
<package id="NUnit.Extension.VSProjectLoader" version="3.2.1" targetFramework="net461" />
<package id="NUnit.Runners" version="3.2.1" targetFramework="net461" />
<package id="NUnit.ConsoleRunner" version="3.4.1" targetFramework="net461" />
<package id="NUnit.Extension.NUnitProjectLoader" version="3.4.1" targetFramework="net461" />
<package id="NUnit.Extension.NUnitV2Driver" version="3.4.1" targetFramework="net461" />
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.4.1" targetFramework="net461" />
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.1" targetFramework="net461" />
<package id="NUnit.Extension.VSProjectLoader" version="3.4.1" targetFramework="net461" />
<package id="NUnit.Runners" version="3.4.1" targetFramework="net461" />
<package id="OpenCover" version="4.6.519" targetFramework="net461" />
<package id="ReportGenerator" version="2.4.5.0" targetFramework="net461" />
<package id="RestSharp" version="105.2.3" targetFramework="net461" />
Expand Down
6 changes: 3 additions & 3 deletions TFSExtension/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ call tsc
if %errorlevel% neq 0 exit /b %errorlevel%
cd ..
echo Building RunOpenCoverTask
xcopy /S /I .\packages\NUnit.ConsoleRunner.3.2.1 .\RunNunitWithOpenCover\dist\NUnit.ConsoleRunner.3.2.1
xcopy /S /I .\packages\NUnit.Extension.NUnitProjectLoader.3.2.1 .\RunNunitWithOpenCover\dist\NUnit.Extension.NUnitProjectLoader.3.2.1
xcopy /S /I .\packages\NUnit.ConsoleRunner.3.4.1 .\RunNunitWithOpenCover\dist\NUnit.ConsoleRunner.3.4.1
xcopy /S /I .\packages\NUnit.Extension.NUnitProjectLoader.3.4.1 .\RunNunitWithOpenCover\dist\NUnit.Extension.NUnitProjectLoader.3.4.1
xcopy /S /I .\packages\OpenCover.4.6.519\tools .\RunNunitWithOpenCover\dist\OpenCover.4.6.519\tools
xcopy /S /I /Exclude:xcopy1.excl .\packages\ReportGenerator.2.4.5.0 .\RunNunitWithOpenCover\dist\ReportGenerator.2.4.5.0
xcopy .\RunNunitWithOpenCover\ResultDummy.xml .\RunNunitWithOpenCover\dist\
xcopy .\RunNunitWithOpenCover\nunit3-junit.xslt .\RunNunitWithOpenCover\dist\
xcopy /S /I .\TFSRestTool\bin\Debug .\RunNunitWithOpenCover\dist\RestHelper

tfx extension create --manifest-globs vss-extension.json --output-path ./bin
8 changes: 8 additions & 0 deletions TFSExtension/details.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This extension includes build step to run Nunit3 with OpenCover and displays result on build page.

The Custom build step is bundeled with the public available nuget packages of
NUnit 3.4.1 https://github.com/nunit/nunit.org and https://github.com/nunit/nunit-transforms
OpenCover 4.6.519 https://github.com/OpenCover/opencover
ReportGenerator 2.4.5.0 https://github.com/danielpalme/ReportGenerator

For Licence Info see the included directories or the corresponding web pages.
12 changes: 11 additions & 1 deletion TFSExtension/vss-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifestVersion": 1,
"id": "coverage-build-tasks",
"name": "RKOS Build Tools",
"version": "0.0.3",
"version": "0.0.4",
"publisher": "RKOS",
"targets": [
{
Expand All @@ -17,6 +17,16 @@
"icons": {
"default": "extension-icon128.png"
},
"links": {
"learn": {
"uri": "https://github.com/RobertK66/vsts-opencover"
}
},
"content": {
"details": {
"path": "details.md"
}
},
"files": [
{
"path": "RunNunitWithOpenCover/dist"
Expand Down
2 changes: 1 addition & 1 deletion docs/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The toolchain for building this Extensions consists of <br>
* e. [Team Foundation command line interface](https://github.com/Microsoft/tfs-cli)(`npm install -g tfx-cli`)

* The versions used for building 0.0.3 are:
* Vs2015-Update2 (including TypeScript tools for Visual Studio 1.8.29.0)
* Vs2015-Update3 (including TypeScript tools for Visual Studio 1.8.34.0)
* node v4.4.4
* npm 3.9.0
* bower 1.7.9
Expand Down

0 comments on commit 31bf7b2

Please sign in to comment.