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