How to do this in Visual Studio Testing Explorer?

Wasenshi Winkung 0 Reputation points

I know I can do this when I run test via command line :

dotnet test myproject.csproj /p:IsTest=true

What if I want to pass that /p:IsTest=true when I run test via Visual studio's Test Explorer? How can I do this?

The Goal:

What I want to do is, selectively excluded some portion of my code from build process only when I want to run Test

in myproject.csproj :

    <DefineConstants Condition=" '$(IsTest)' == 'true' ">$(DefineConstants);TEST</DefineConstants>

This will allow me to put any codes behind #if TEST ... #endif or #if !TEST ... #endif

So I want to know if I can apply this concept when I run test from the Visual Studio itself rather than run test in cmd myself.

A cross-platform toolchain for developing, building, running, and publishing .NET applications.
295 questions
Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
285 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Wasenshi Winkung 0 Reputation points

    I have found a solution. Basically, just create a new build config specifically for Unit Test and use this before running the Test via Visual Studio's.

    enter image description here

    In this new build config, I can setup directly in each project of what property/symbols I needed.

    User's image

    0 comments No comments