简体   繁体   中英

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.

I want to investigate with Visual Studio Code, but I can't figure out how to run the test in Release mode. I can't seem to find any VSCode dialog to change the mode, nor (surprisingly) any SO questions that address this specifically.

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. 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": "${workspaceFolder}/bin/Release/<YourProject>.dll"

After saving the changes, the "Run Test" link should now run it in Release mode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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