Two parts need file .runsettings
when you work with VS Code:
- when
build
tests in VS Code, it firstly run vstest.exe
with parameters
- when
run
tests in VS Code, it need mstest.exe
.
For the first part, here is the document for .NET Core Test Explorer:
https://github.com/formulahendry/vscode-dotnet-test-explorer
The settings are available via File / Preferences / Settings. Navigate
to extensions and .NET Core test explorer.
Additional arguments that are added to the dotnet test command. These
can for instance be used to collect code coverage data
("/p:CollectCoverage=true /p:CoverletOutputFormat=lcov
/p:CoverletOutput=../../lcov.info") or pass test settings
("--settings:./myfilename.runSettings")
But above settings are global, you can setup from .vscode\workspace.code-workspace
file for specified test project only:
{
"folders": [
{
"path": ".."
}
],
"settings": {
"dotnet-test-explorer.testArguments": "--settings .runsettings",
"dotnet-test-explorer.testProjectPath": "**/test.project.name.csproj"
}
}
For the second part, we need a new feature RunSettingsFilePath that's delivered from VS 2019 16.4.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RunSettingsFilePath>$(MSBuildProjectDirectory)\.runsettings</RunSettingsFilePath> // or $(SolutionDir)
</PropertyGroup>
...
</Project>