vstest.console.exe没有发现Xunit测试 [英] No xunit tests discovered by vstest.console.exe

查看:93
本文介绍了vstest.console.exe没有发现Xunit测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在整理一堆新的单元测试,以作为CI作业一起运行.我之所以使用vstest.console.exe而不是mstest.exe,主要是因为它能够从多个框架运行测试,但是现在的焦点是几个xUnit dll.这些作业作为Jenkins管道的一部分运行.

I'm putting together a new stack of unit tests to be run together as a CI job. I'm using vstest.console.exe instead of mstest.exe mainly for its ability to run tests from several frameworks, but right now the focus is a few xUnit dlls. The jobs are run as part of a Jenkins pipeline.

我已经在几个开发箱上成功测试了所有内容,但是到目前为止,令人讨厌的测试发现不适用于任何CI构建箱.这是在添加0.99.8 xUnit测试适配器vsix(也已使用0.99.7测试)之后. xUnit dll是使用xUnit的2.0.0.2378 beta nuget版本针对4.5构建的.

I have tested everything successfully on a couple of dev boxes, but annoyingly test discovery is not working on any of the CI build boxes so far. This is after the addition of the 0.99.8 xUnit test adapter vsix (also tested with 0.99.7). The xUnit dlls are being built against 4.5 with the 2.0.0.2378 beta nuget version of xUnit.

我用最简单的dll,单一的公共测试方法重现了这些症状,在我自己的盒子上工作正常,而不在任何构建盒子上工作.部署环境非常简单,在Windows 2012上安装了VS2012和xUnit测试适配器.

I have reproduced the symptoms with the simplest possible dll, with a single public test method, working fine on my own box, not working on any build boxes. The deployment enviroment is pretty straight forward, with a VS2012 install and the xUnit test adapter, on Windows 2012.

我已经通过vstest exe配置文件启用了TpTrace日志记录,一切看起来都很好.我想我正在寻找一种进一步解决问题的方法(可能是针对xUnit发现过程的跟踪)或解决该问题的方法.为了简化运行多个框架的工作,我希望保留使用vstest控制台.

I have enabled the TpTrace logging via the vstest exe config files and everything looks fine. I guess I'm looking for a way to troubleshoot the issue further (maybe tracing for the xUnit discovery process) or a workaround the problem. I'd prefer to retain the use of vstest console for the simplicity of running several frameworks.

我也通过 xUnit codeplex 网站写下了这个问题.

I have written up this issue via the xUnit codeplex site as well.

我已经检出了这个 SO帖子,但是这里没有建议的解决方案.

I've checked out this SO post but none of the suggested solutions make sense here.

推荐答案

花了我很多时间才能找到关于如何在VS2013中使用vstest.console.exe和xunit的解决方案,所以我认为值得在这里解释一下如何我为所有人做了...

It takes me quite some time to find the solution of how to use vstest.console.exe and xunit for VS2013, so I think it worth the time to explain here how I did for everyone...

第一步是按照此处中的解释进行操作在需要它才能在Visual Studio中运行xunit测试的xunit项目中安装预发布的xunit.runner.visualstudio nuget软件包.

The first step is to follow what is explained here to install the pre-release xunit.runner.visualstudio nuget package in the xunit projects that need it to be able to run the xunit test from Visual Studio.

然后,当您运行vstest.console.exe命令时,您必须使用参数/TestAdapterPath.

Then, when you run your vstest.console.exe command, you MUST use the parameter /TestAdapterPath.

您的命令行应该看起来像什么(指向xunit适配器的路径在这里是相对的,因此,您可以将其置于绝对位置或根据活动目录进行调整):

Your command line should look like something (the path toward the xunit adapter is here relative so, you could put it in absolute or adapt depending on the active directory):

"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" c:\path\to\your\assembly.to.test.dll /TestAdapterPath:".\packages\xunit.runner.visualstudio.0.99.9-build1021\build\_common\"

edit:因为适配器dll被复制到输出文件夹,所以我们可以简化命令行并给出路径.".到/TestAdapterPath选项:

edit: Because the adapter dlls are copied to the output folder, we could simplify the command line giving the path "." to the /TestAdapterPath option:

"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" c:\path\to\your\assembly.to.test.dll /TestAdapterPath:"."

有关信息,它还可以与NUnit,nuget包NUnitTestAdapter和以下命令一起使用:

For information, it works also with NUnit, nuget package NUnitTestAdapter and the command:

"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" c:\path\to\your\assembly.to.test.dll /TestAdapterPath:"."

这篇关于vstest.console.exe没有发现Xunit测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆