nunit / dotnet-test-nunit

Deprecated test runner for .NET Core. For use with project.json only. For recent releases of .NET Core, use the NUnit 3 Visual Studio Adapter
https://www.nuget.org/packages/dotnet-test-nunit/
MIT License
67 stars 25 forks source link

Support NUnit2 format #75

Open jirisykora83 opened 8 years ago

jirisykora83 commented 8 years ago

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

rprouse commented 8 years ago

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.

CharliePoole commented 8 years ago

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. :-)

jirisykora83 commented 8 years ago

@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.

CharliePoole commented 8 years ago

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

corsairmarks commented 8 years ago

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

AlexKosmich commented 7 years ago

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

allendm-msft commented 7 years ago

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

rprouse commented 7 years ago

@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.

atinb commented 7 years ago

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

scotmeiste commented 7 years ago

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)

rprouse commented 7 years ago

@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?

harrisonmeister commented 7 years ago

@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.

rprouse commented 7 years ago

@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 😄

scotmeiste commented 7 years ago

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"

atinb commented 7 years ago

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

CharliePoole commented 7 years ago

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 notifications@github.com 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 .

jirisykora83 commented 7 years ago

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

PBoraMSFT commented 7 years ago

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