简体   繁体   中英

NUnit 3 console runner - How to run a specific .playlist file?

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.

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!

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM