This extension allows you to run your Boost.Test tests
from the Testing sidebar of VS Code.
Screenshot
Features
Tests will appear in the Testing sidebar of VS Code.
run or debug tests
from the Testing sidebar
from inside test source code
Output
Test output appears in the Test Output Terminal of the Testing sidebar.
During debugging the test output appears in the corresponding Terminal.
Diagnostic info appears in the Boost.Test Adapter Output channel.
Configurations
"boost-test-adapter-tinydevel.tests": [
{
// Mandatory
"testExecutables": [
{
// Mandatory: Path to a test executable. May be absolute or relative path.
"path": "build/Debug/main_test_1",
// Optional: Show this label in the Testing sidebar instead of the Boost Test module name.
"label": "Test 1 (debug)"
},
{
"path": "build/Release/main_test_1",
"label": "Test 1 (release)"
},
{
"path": "build/Debug/main_test_2"
}
],
// Optional: The working directory for the test executables.
"cwd": "${workspaceFolder}",
// Mandatory: The name of a launch configuration that should be used
// when debugging the tests.
// The 'program' and 'args' options of the given launch config will
// be overwritten by this extension.
"debugConfig": "Test config",
// Optional: A simple key=value file with environment variables for running and debugging the tests.
"envFile": "${workspaceFolder}/.env",
// Optional: Environment variables for running and debugging the tests.
// These env vars are merged with the ones from envFile (if present).
// These env vars take precedence over the ones from envFile.
"env": [
{
"name": "MY_VAR",
"value": "my var value"
}
],
// Optional: Used to convert relative source file paths to absolute paths.
// It's needed only if the test-case file paths are broken in the Test Explorer UI.
"sourcePrefix": "${workspaceFolder}"
},
{
"testExecutables": [ "build/Debug/other_test_2" ],
"cwd": "${workspaceFolder}",
"debugConfig": "Test config"
}
]
FAQ
I don't see any tests in the Testing sidebar. Why?
Make sure you have configured your settings.json and launch.json properly.
Take a look at the Boost.Test Adapter Output channel for potential issues.
Press the reload button at the top of the Testing sidebar.
Restart VS Code.
What is this weird root node in the test tree?
That is your workspace name.
Why does the path of the tests change when I open them?
Tests are not loaded from the test execuatbles immediately. They are loaded only
when requested (i.e. when you open them). At that point the Test Module name is fetched
from the test executable and it replaces the test exe path.
The test exe path is still available from the context menu's Copy Path command.
Why is the file system path of my Test Suite point to the wrong source file?
Probably because you have the same Test Suite declared in multiple source files.
Why is my test-root called "Hello World" (or some other nonsense) in the Testing sidebar?
That is the Boost test module name. It comes from your test executable.
Usually from a line like this:
#define BOOST_TEST_MODULE Hello World
Features not implemented yet
When debugging a test, the red/green status of the test is not updated in the UI.
Credits
This extension is based on code from these extensions: