Skip to content

bneumann/CppUTest-Test-Adapter

Repository files navigation

CppUTest Test Adapter for Visual Studio Code

Tests

A Visual Studio Code extension that integrates the CppUTest C/C++ unit testing framework into VS Code's Test Explorer. Run, debug, and manage your CppUTest tests seamlessly within your development environment.


Features

  • Run and debug CppUTest tests directly from VS Code.
  • Supports multiple test executables and wildcards for flexible test discovery.
  • Pre-launch tasks to build tests before execution.
  • Logging support for debugging and troubleshooting.

Setup

1. Configure Test Executables

Add the following to your VS Code settings.json to specify your test executables:

{
  "cpputestTestAdapter.testExecutable": "${workspaceFolder}/test/testrunner;${workspaceFolder}/test/subFolder/ut_*",
  "cpputestTestAdapter.testExecutablePath": "${workspaceFolder}/test"
}
  • testExecutable: Path(s) to your test executables. Supports wildcards (*) and semicolon-separated lists.
  • testExecutablePath: Working directory for running tests. If not set, each executable runs from its own directory.

Both settings support the ${workspaceFolder} variable.

Pre-Launch Task (Optional)

To rebuild your tests before running, define a task in tasks.json and reference it:

{
  "cpputestTestAdapter.preLaunchTask": "build-tests"
}

Logging

Enable logging for debugging:

{
  "cpputestTestAdapter.logpanel": true,
  "cpputestTestAdapter.logfile": "C:/temp/cpputest-adapter.log"
}
  • logpanel: Shows logs in VS Code's Output panel ("CppUTest Test Adapter Log").
  • logfile: Saves logs to a file. Use absolute paths and ensure the directory exists.

Ignore Stderr

By default, any output to stderr is treated as a test failure. If your tests produce warnings or logs on stderr without actually failing, you can disable this behavior:

{
  "cpputestTestAdapter.ignoreStderr": true
}
  • When true, stderr output is not automatically treated as test failure. Tests are marked as failed only if actual failure markers are detected in the output.

Max Buffer Size

If you encounter ERR_CHILD_PROCESS_STDIO_MAXBUFFER errors with tests that produce large output, increase the buffer size:

{
  "cpputestTestAdapter.maxBuffer": 104857600
}
  • Default is 1MB (1048576 bytes). The example above sets it to 100MB.

Debugging

To debug your tests, configure your launch.json like you would with any debugger (in this case gdb):

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug CppUTest",
      "type": "cppdbg",
      "request": "launch",
      "program": "${workspaceFolder}/test/testrunner",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "externalConsole": false,
      "MIMode": "gdb",
      "miDebuggerPath": "/path/to/gdb"
    }
  ]
}
  • The adapter automatically attaches to the test process.

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

About

A test adapter for Visual Studio Code for the C/C++ Unit Test framework CppUTest.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors