简体   繁体   English

在带有 C# 的 Visual Studio Code 中,如何在发布模式下运行 NUnit 测试?

[英]In Visual Studio Code with C#, how do I run an NUnit test in Release mode?

I have an NUnit test that fails only in Release config, and not Debug config.我有一个 NUnit 测试只在发布配置中失败,在调试配置中没有。

I want to investigate with Visual Studio Code, but I can't figure out how to run the test in Release mode.我想使用 Visual Studio Code 进行调查,但我不知道如何在发布模式下运行测试。 I can't seem to find any VSCode dialog to change the mode, nor (surprisingly) any SO questions that address this specifically.我似乎找不到任何 VSCode 对话框来更改模式,也找不到(令人惊讶的)任何专门解决此问题的 SO 问题。

Specifically, I want to click this "Run Test" link and have it run in Release mode:具体来说,我想单击此“运行测试”链接并让它在发布模式下运行:

在此处输入图像描述

You can change the configuration in the launch.json file, located in the.vscode folder.您可以更改位于 .vscode 文件夹中的launch.json文件中的配置。 The config for running tests should look something like this:运行测试的配置应如下所示:

{
  "name": "Unit Tests",
  "type": "dotnet",
  "request": "launch",
  "program": "${workspaceFolder}/bin/Debug/<YourProject>.dll",
  "args": [
    "--filter",
    "cat==Unit"
  ],
  "cwd": "${workspaceFolder}",
  "console": "integratedTerminal"
}

You need to change the value of the "program": field to point to the Release version of your project's DLL file, for example:您需要更改"program":字段的值以指向您项目的 DLL 文件的发布版本,例如:

"program": "${workspaceFolder}/bin/Release/<YourProject>.dll"

After saving the changes, the "Run Test" link should now run it in Release mode.保存更改后,“运行测试”链接现在应该以发布模式运行它。

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

相关问题 如何从Visual Studio以调试模式运行NUnit? - How do I run NUnit in debug mode from Visual Studio? 在 Visual Studio 代码中运行 Selenium NUnit C# - Run Selenium NUnit C# in Visual Studio Code 我可以在 Visual Studio/Code 中测试/运行 Unity C# 吗? - Can I test/run Unity C# in Visual Studio/Code? 如何通过Visual Studio创建和运行NUnit / WebDriver测试套件? - How do I create and run NUnit/WebDriver test-suites via Visual Studio? 如何通过NUnit中的C#代码运行特定的测试类 - How to run specific test class via c# code in NUnit C#Microsoft Visual Studio发行模式 - C# Microsoft Visual Studio Release Mode 如何同时在多个浏览器上运行测试? 硒网格,C#,Specflow,NUnit - How do I run a test on multiple browsers at the same time? Selenium Grid, C#, Specflow, NUnit 如何使用NUnit 3(C#)从代码运行特定的NUnit测试 - How to run a specific NUnit test from code using NUnit 3 (C#) 如何在Visual Studio中以调试模式运行NUnit? - How to run NUnit in debug mode from Visual Studio? UWP 应用程序在 Visual Studio 调试模式下工作,但发布版本无法运行,缺少 DLL (C#) - UWP App works in Visual Studio debug mode, but the release build won't run, missing DLL (C#)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM