如何在不构建项目的情况下在命令行中运行xUnit测试DLL [英] How to run xUnit test DLL in Commandline without building the project

查看:218
本文介绍了如何在不构建项目的情况下在命令行中运行xUnit测试DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.NET Core中有一个项目,并已使用xUnit构建了测试。现在,我想在部署过程中运行测试。到目前为止,我已经完成了什么:

I have a project in .NET Core and have built tests using xUnit. Now I wanted to run the test in deployment process. What I have done so far:

我在命令行中使用了以下命令:

I used this command in commandline:

dotnet test [project address]  ... 

它正在工作,但问题是命令获取 .csproj 文件,而不获取 dll

it is working but the problem is that this command get the .csproj file and not the dll.

我安装并使用了 xunit.runner.console ,但它不适用于.NET Core项目。

I installed and used xunit.runner.console but its not working with .NET Core projects.

I使用 dotnet xunit 命令,这一命令也无济于事,虽然我不能给它 dll ,但它也使用了项目文件夹。

I used dotnet xunit command, this one also not helped while I cannot give it the dll it is also using the project folder.

我可以使用什么来运行构建的测试(不要再次构建它们),我可以提供测试的任何命令行工具 dll 作为输入,它将为我运行测试。

What can I use to run my built test (dont want to build them again), any commandline tools that I can give my test dll as an input and it runs the test for me.

推荐答案

您在这里有几种选择:

dotnet vstest Foo.dll

dll 运行测试。支持xUnit测试。 文档

to run tests from a dll. xUnit tests are supported. Documentation.

仅一个 dll 文件是不够的。从 bin 文件夹运行 dotnet vstest ,该文件夹通常包含:

A single dll file only is not enough. Run dotnet vstest from your bin folder, which usually contains:

Foo.dll
Foo.deps.json
Foo.runtimeconfig.json
Foo.runtimeconfig.dev.json
Microsoft.Extensions.Logging.Test.dll
xunit.runner.reporters.netstandard15.dll
xunit.runner.utility.netstandard15.dll
xunit.runner.visualstudio.dotnetcore.testadapter.dll

bin 输出对于运行测试是必需的。

This bin output is necessary to run the tests.

dotnet test --no-build

这篇关于如何在不构建项目的情况下在命令行中运行xUnit测试DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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