In Visual Studio Code, I am really confused by the 3 "Context" menu items: Run Tests in Context
and Debug Tests in Context
and Run .NET Core Test in context
, what Context
are they expecting?
In my understanding, TestContext
will be initialized via .runsettings
, but I am never able to pass the runsettings
on Debugging/Running Tests in Context
from VS code.
[ClassInitialize]
public static new void ClassInitialize(TestContext testContext)
{
//testContext doesn't get setting from `.runsettings`
...
BaseTest.ClassInitialize(testContext);
}
I believe the following Debug Test
is different with Debug Tests in Context
? because the follow Run Test
can load runsettings
, but Debug Test
doesn't work.
Above Run Test
work with following settings:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RunSettingsFilePath>$(MSBuildProjectDirectory)\example.runsettings</RunSettingsFilePath>
</PropertyGroup>
...
</Project>
My tests work well in Visual Studio 2019, but stuck in VS Code on loading .runsettings
.
For more details:
Here is my folder structure:
Here is the content of workspace.code-workspace
, and dotnet-test-explorer
works well with it to load all tests:
{
"folders": [
{
"path": ".."
}
],
"settings": {
"dotnet-test-explorer.testArguments": "--settings c:/src/pat-oas/.runsettings",
"dotnet-test-explorer.testProjectPath": "./tests/Pat.UITests.Itrds/Pat.UITests.Itrds.csproj"
}
}