简体   繁体   English

如何在没有 Visual Studio 和源代码的情况下运行 NUnit 测试?

[英]How to run NUnit tests without Visual Studio and Source code?

I am very new to Unit-Testing.我对单元测试很陌生。

I have a solution with C# project.我有一个 C# 项目的解决方案。 I added to it a new NUnit project and added some tests.我向其中添加了一个新的 NUnit 项目并添加了一些测试。

I can run my tests using Test Explorer of Visual Studio, and even using Command-Line in the developing platform:我可以使用 Visual Studio 的测试资源管理器运行我的测试,甚至可以在开发平台中使用命令行:

D:\Project\GuiTests\bin\Debug\netcoreapp2.1>dotnet test GuiTests.dll

I want to do a similar thing, but on a testing platform, which does not have Visual Studio and the source code.我想做类似的事情,但是在一个没有 Visual Studio 和源代码的测试平台上。

I want to copy there only the tests folder (ie D:\Project\GuiTests\bin\Debug\netcoreapp2.1) and run the tests using Command-Line.我只想复制测试文件夹(即 D:\Project\GuiTests\bin\Debug\netcoreapp2.1)并使用命令行运行测试。

Is it possible?可能吗? How can I do that?我怎样才能做到这一点?

Currently, I tried it out and got:目前,我尝试了一下并得到:

在此处输入图像描述

=== ===

I tried using nunit-console and got this error:我尝试使用 nunit-console 并收到此错误:

Could not load file or assembly 'nunit.framework, Version=3.10.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb' or one of its dependencies.无法加载文件或程序集 'nunit.framework, Version=3.10.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb' 或其依赖项之一。

Googling it, seems nunit-console does not support.Net Core.谷歌搜索,似乎 nunit-console 不支持.Net Core。

So I think I should go on with the dotnet test所以我想我应该用dotnet test go

You can read the documentation of NUnit Console Command Line您可以阅读NUnit Console Command Line的文档

The console interface runner is invoked by a command in the form控制台界面运行器由表单中的命令调用
NUNIT3-CONSOLE [inputfiles] [options]
where inputfiles is one or more assemblies or test projects of a type that NUnit can process and options is zero or more options.其中 inputfiles 是一个或多个 NUnit 可以处理的类型的程序集或测试项目,而 options 是零个或多个选项。 Input files and options may be mixed in any order.输入文件和选项可以按任何顺序混合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM