0

Is it possible to use the NUnit3 Console Runner to run a .playlist file saved from Visual Studio's Test Explorer?

I looked into the documentation but couldn't find anything for a .playlist file. Only for a file containing a list of project names. But a list is different from a xml .playlist file.

MuhKuh
  • 356
  • 1
  • 16

2 Answers2

1

Figured I'd save someone else the trouble. I put together a stylesheet that will convert these into the text files that NUnit needs. I named it ToText.xlst.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
    <xsl:template match="Add">
        <xsl:value-of select="@Test" />
        <!-- adds a newline -->
        <xsl:text>&#xa;</xsl:text>
    </xsl:template>
    <xsl:template match="@* | node()">
        <xsl:apply-templates select="*" />
    </xsl:template>
</xsl:stylesheet>

Find a copy of saxon and run it like this:

set SAXON="path/to/saxon-a.b.c.d.jar"
java -jar %SAXON% -s:"path/to/Unit Test Playlists/Fast.playlist" -xsl:"path/to/Unit Test Playlists/ToText.xslt" -o:"path/to/Unit Test Playlists/Fast.txt"
Chris
  • 3,400
  • 1
  • 27
  • 41
0

No, there is currently no option to run a Visual Studio .playlist file in the core functionality of the console runner.

The closest equivalent currently in NUnit is --testList, which is a file just containing the names of every test. Looking at a playlist file, it looks like it would be simple-ish to write something to extract the testnames from a playlist and turn it into a testlist.

The other thing I thought briefly about was whether it would be possible to implement a .playlist file reader using the NUnit Console extensibility functionality. I don't think it would be currently - as there's no extensibility around setting the test filter - but someone may correct me on that one. Would be an interesting new feature for the extensibility too!

Chris
  • 5,882
  • 2
  • 32
  • 57
  • 1
    Thanks, I will build a parser to extract the contents, and add it in front of the TestScript running the console runner. – MuhKuh Jan 04 '19 at 14:28
  • @MuhKuh - actually, is there a particular reason you need to use the nunit console runner, rather than `dotnet test` on the command line? I believe `dotnet test` can read a playlist file. – Chris Jan 04 '19 at 14:34