How to run xUnit test DLL in Commandline without building the project

拈花ヽ惹草 提交于 2019-12-13 12:25:11

问题


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]  ... 

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

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

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

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.


回答1:


You have several options here:

1. Use vstest command

dotnet vstest Foo.dll

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

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

This bin output is necessary to run the tests.

2. Skip the project build on test run

dotnet test --no-build


来源:https://stackoverflow.com/questions/44590050/how-to-run-xunit-test-dll-in-commandline-without-building-the-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!