dotnet-test-nunit icon indicating copy to clipboard operation
dotnet-test-nunit copied to clipboard

Support NUnit2 format

Open jirisykora83 opened this issue 9 years ago • 18 comments

Hello there, it is possible add NUnit2 format because Visual Studio Team Services doesn't support NUnit3 format.

jirisykora83 avatar Aug 22 '16 15:08 jirisykora83

We didn't include the NUnit 2 format because we were hoping that third party vendors like VSTS would have updated by now. I would like to see vendors update to the new format because it contains more information and am reluctant to add support for NUnit 2 to newer tools to encourage vendors to update.

I understand the need though, so am going to leave this issue open as an enhancement. I would also appreciate more feedback from the community.

rprouse avatar Aug 22 '16 19:08 rprouse

Additionally, it might be worthwhile to wait and see how much we are able to bring together the engine code and this project's. We already have two implementations of the nunit 2 format writer (engine and nunitlite) which seems to me like one too many. :-)

CharliePoole avatar Aug 22 '16 21:08 CharliePoole

@rprouse It's really disappointing for me, but VSTS does not support NUinit format. Currently workaround is using XML transformation via Powershell. If somebody else want get NUnit3 format to VSTS i can share it.

jirisykora83 avatar Aug 27 '16 20:08 jirisykora83

As a workaround, you could leverage the code for NUnit's V2 result writer, which takes an XmlNode in V3 format and creates an output file in V2 format.

https://github.com/nunit/nunit-console/tree/master/src/NUnitEngine/Addins/nunit-v2-result-writer

CharliePoole avatar Aug 27 '16 20:08 CharliePoole

Looks like there are not a lot of votes for this on User Voice for VSTS: https://visualstudio.uservoice.com/forums/330519-team-services/suggestions/15864978-nunit-3-results-format-does-not-appear-to-be-suppo

corsairmarks avatar Sep 06 '16 16:09 corsairmarks

@jirisykora83 Could you please share the details regarding XML transformation to V2?

AlexKosmich avatar Sep 09 '16 10:09 AlexKosmich

@jirisykora83 I've raised a PR to support nunit3 output xml. Do review if you get a chance Microsoft/vsts-agent#629

allendm-msft avatar Oct 12 '16 06:10 allendm-msft

@CharliePoole, you and I should review Microsoft/vsts-agent#629 when we get a chance. I've done an initial review and don't see anything obvious that hasn't already been commented on. I will try to do a more thorough review when I get a chance.

rprouse avatar Oct 12 '16 13:10 rprouse

@rprouse @CharliePoole Would really appreciate if one of you can review the PR. NUnit3 support is a highly requested feature for VSTS. Thanks!

atinb avatar Oct 18 '16 15:10 atinb

We are using Atlassian Bamboo and writing a .net core app and bamboo currently only supports the version 2 format of the xml result file.

Are there any workarounds to get it the nunit3 results into the nunit2 format while we wait for Atlassian to catch up? (they are slated to support nunit 3 in their next release, but not sure when that will be available)

scotmeiste avatar Oct 19 '16 18:10 scotmeiste

@harrisonmeister and @CharliePoole do you think the NUnit Summary project could do an NUnit 3 to NUnit 2 XML transform or would it be too much work?

rprouse avatar Oct 19 '16 21:10 rprouse

@rprouse - my gut feeling is that it would be quite a large piece of work, though I'm not 100% familiar with the differences between the 2 outputs.

harrisonmeister avatar Oct 20 '16 07:10 harrisonmeister

@harrisonmeister thanks, you are probably right. I was just thinking this might be a way to not have to support the NUnit 2 format everywhere. It would be easier if everyone updated their products to read the NUnit 3 format 😄

rprouse avatar Oct 20 '16 20:10 rprouse

FWIW - I contacted Atlassian and they said the next version (the one slated to support nunit 3) is estimated to be out "by the end of the month"

scotmeiste avatar Oct 20 '16 20:10 scotmeiste

@rprouse @CharliePoole Will really like to get your review before checking in. Will it be possible for you to take a look? Thanks!

atinb avatar Oct 23 '16 15:10 atinb

Writing a transform to go from NUnit 3 to NUnit 2 format would seem like a waste of time, given that we already have C# code that does the same thing cleanly encapsulated in an assembly. The only issue is that it's in the form of an engine extension. Where does that code need to be usable in order to make folks happy?

Ideally, point me to a particular line in a particular file where you have the NUnit 3 XML available and want to produce NUnit 2 output. That's what I plan to do for NUnitLite.

On Thu, Oct 20, 2016 at 1:23 PM, Scot Meiste [email protected] wrote:

FWIW - I contacted Atlassian and they said the next version (the one slated to support nunit 3) is estimated to be out "by the end of the month"

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nunit/dotnet-test-nunit/issues/75#issuecomment-255217541, or mute the thread https://github.com/notifications/unsubscribe-auth/ACjfhQ1RHz0e4nOAm0myD_mVpc_YYeOsks5q183MgaJpZM4JqA_c .

CharliePoole avatar Oct 25 '16 18:10 CharliePoole

Because almost after 6 months VSTS still not supporting NUnit 3 format, i want to share workaround which i currently use.

VSTS support JUnit format. And i using this xslt file for transform NUnit 3 format to Junit.

Here is the powershell script for run NUnit tests and convert result to JUnit. Probably it is not optimal, but for me it's work fine.

param(
    [string]$sourcesDirectory,
    [string]$fileFilters,
    [bool]$toJunit
)

Write-Output "Start RunAndConvertUnitTests.ps1"
Write-Output "sourcesDirectory = $sourcesDirectory"
Write-Output "fileFilters = $fileFilters"

# Set all arguments and execute the unit console
New-Item -ItemType Directory -Force -Path TEST-RESULTS | Out-Null

# Run all tests
Write-Output "Run tests.."
[array]$files = Get-ChildItem -Path $sourceDirectory -include $fileFilters -recurse | Select-Object -expand FullName
foreach ($file in $files)
{
    $outDir = ([uri]$file).segments[-1]
    & dotnet test $file\project.json --result "TEST-RESULTS\$outDir.xml"
}

if($toJunit)
{
    Write-Output "Convert to JUnit"
    [array]$resultFiles = Get-ChildItem -Path ./TEST-RESULTS -include *.xml -recurse | Select-Object -expand FullName
    foreach ($file in $resultFiles)
    {
        $fileName = [io.path]::GetFileNameWithoutExtension($file)
        $xslt = New-Object System.Xml.Xsl.XslCompiledTransform
        $xslt.Load("$PSScriptRoot/nunit3-junit.xslt")
        $xslt.Transform($file, "$pwd/TEST-RESULTS/$fileName-junit.xml")
    }
}

Here is example how use it from VSTS. unnamed

jirisykora83 avatar Feb 25 '17 20:02 jirisykora83

Hello, Support for NUnit 3 results format will be available soon. Here's the PR https://github.com/Microsoft/vsts-tasks/pull/3650

PBoraMSFT avatar Feb 27 '17 05:02 PBoraMSFT