通过命令行运行 NUnit 测试时使用 runsettings 文件 [英] Using runsettings file when running NUnit tests via command line

查看:60
本文介绍了通过命令行运行 NUnit 测试时使用 runsettings 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个如下所示的运行设置文件

I created a runsettings file which looks like this

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <TestRunParameters>
    <Parameter name ="environment" value="PROD" />
  </TestRunParameters>
</RunSettings>

然后在我的 TestSetup 部分(使用 LeanFT 进行 UI 测试)我指定目标环境包含在名为 environment 的参数下

And then in my TestSetup portion (using LeanFT for UI tests) I specify that the target environment is contained under a paramater called environment

string env= TestContext.Parameters["environment"];

这似乎不起作用,而且我没有收到任何特定的错误消息.这是执行此操作的正确方法,还是有更简单的方法来使用 Environment 和我传递到命令行的内容.

This doesnt seem to work, and I am not getting any particular error messages. Is this the right way to do this, or is there an easier way to just use Environment and something I pass into the command line.

推荐答案

您应该比通过命令行"更具体,因为人们可以通过多种方式从命令行运行 NUnit 测试.

You should be more specific than "via the commandline" since there are a number of ways that folks run NUnit tests from the command-line.

如果您使用的是 nunit3-console.exe 运行器,则使用 --params 选项将运行参数传递给框架,例如:

If you are using the nunit3-console.exe runner, you pass run parameters to the framework using the --params option, for example:

<代码>nunit3-console my.test.dll --params "environment=PROD"

.runsettings 文件是 Visual Studio 使用的工件,由 NUnit VS 适配器识别,但不能由 NUnit 本身识别.

The .runsettings file is an artifact used by Visual Studio and recognized by the NUnit VS adapter, but not by NUnit itself.

您也可以从命令行使用它,使用 vstest.console.exe.如果这是您使用的,您需要 /Settings 选项来指定文件.

You can use that from the command-line as well, using vstest.console.exe. If that's what you are using, you want the /Settings option in order to specify the file.

一个的价格有两个答案!但是,如果您使用 nunit-console nor vstest.console,您将不得不再次询问.;-)

Two answers for the price of one! But if you are using neither nunit-console nor vstest.console you'll have to ask again. ;-)

这篇关于通过命令行运行 NUnit 测试时使用 runsettings 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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