[英]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? 是否可以使用NUnit3控制台运行器来运行从Visual Studio的测试资源管理器中保存的
.playlist
文件?
I looked into the documentation but couldn't find anything for a .playlist
file. 我查看了文档,但找不到
.playlist
文件的任何内容。 Only for a file containing a list of project names. 仅适用于包含项目名称列表的文件。 But a list is different from a xml
.playlist
file. 但是列表与xml
.playlist
文件不同。
No, there is currently no option to run a Visual Studio .playlist
file in the core functionality of the console runner. 不,当前在控制台运行程序的核心功能中没有运行Visual Studio
.playlist
文件的选项。
The closest equivalent currently in NUnit is --testList
, which is a file just containing the names of every test. 当前在NUnit中最接近的等效项是
--testList
,这是一个仅包含每个测试名称的文件。 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. 我简要考虑过的另一件事是,是否可以使用NUnit Console扩展功能来实现
.playlist
文件阅读器。 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.
我整理了一个样式表,将其转换为NUnit所需的文本文件。 I named it
ToText.xlst
. 我将其命名为
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>
</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"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.