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.
In this new build config, I can setup directly in each project of what property/symbols I needed.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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 :
<PropertyGroup>
...
<DefineConstants Condition=" '$(IsTest)' == 'true' ">$(DefineConstants);TEST</DefineConstants>
</PropertyGroup>
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.
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.
In this new build config, I can setup directly in each project of what property/symbols I needed.