Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass parameters in visual studio 2017 like nunit-console params cli

If i run my unit tests using NUnit's nunit3-console CLI utility I'm able to pass parameters using the "params" flag like so:

>nunit3-console --params:testKey=test203 TestClass.dll

Debugging in VS is really annoying because I have to set the flag "--debug", i then have to attach to the process from visual studio. My question is whether it's possible to somehow pass in that same parameter to my unit tests using only visual studio?

The reason I need to pass in params this way is because I need it in my setup methods and Nunit does not allow me to dynamically change it using a variable.

like image 600
so cal cheesehead Avatar asked Jan 30 '23 02:01

so cal cheesehead


1 Answers

You specify the run parameters in your .runsettings file. Here's what an example file with no other settings would look like...

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>

  <TestRunParameters>
    <Parameter name="webAppUrl" value="http://localhost" />
    <Parameter name="webAppUserName" value="Admin" />
    <Parameter name="webAppPassword" value="Password" />
  </TestRunParameters>

</RunSettings>
like image 172
Charlie Avatar answered Feb 02 '23 09:02

Charlie