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

查看:32
本文介绍了如何在不构建项目的情况下在命令行中运行 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.

我使用了 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天全站免登陆