C# Test Filter Helper
Automatically detect C# test scope (assembly, class, and method) at your
cursor position for seamless TUnit debugging in VS Code.
Features
- Automatic Test Scope Detection: Uses C# Language Server for accurate
symbol detection
- TUnit Filter Generation: Generates proper TUnit
--treenode-filter
format
- Debug Integration: Works seamlessly with VS Code's launch.json
- Class & Method Level: Run entire test classes or individual methods
- Last Test Memory: Remembers your last selected test method and uses it
automatically when cursor is not on a test
- Fallback Support: Works even without C# Dev Kit installed
Quick Start
1. Add the Debug Configuration
Easy way: Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and run
"C# Test Filter: Add Debug Configuration" - this automatically creates
the launch.json with all required settings.
Manual way: Add this to your .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug TUnit Test",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${input:dllPath}",
"args": [
"--treenode-filter",
"${input:testFilter}"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"stopAtEntry": false
}
],
"inputs": [
{
"id": "dllPath",
"type": "command",
"command": "csharp-test-filter.getDllPath"
},
{
"id": "testFilter",
"type": "command",
"command": "csharp-test-filter.getFilter"
}
]
}
Note: The getDllPath command automatically finds the correct DLL path based
on your current test file's project. This works with multiple test projects -
just open a test file from any project and debug!
2. Set Breakpoints & Debug
- Open any C# test file
- Place cursor in a test method (or on class name for all tests)
- Set breakpoints
- Press F5 to debug
The extension automatically detects your test scope and runs only the
relevant tests.
Tip: The extension remembers your last selected test method. If you move
your cursor away from tests, it will automatically reuse the last test you
selected!
Commands
- C# Test Filter: Add Debug Configuration - Adds the TUnit debug
configuration to your launch.json (creates file if needed)
- C# Test Filter: Get Current Test Scope - Shows detected test
information
- C# Test Filter: Copy Test Filter to Clipboard - Copies the filter
string
Access via Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
The extension generates TUnit-compatible filters:
- Method Level:
/*/Namespace/ClassName/MethodName
- Class Level:
/*/Namespace/ClassName/*
Requirements
- VS Code 1.85.0 or higher
- .NET SDK with C# project
- Recommended: C# Dev Kit extension for best results
Extension Settings
csharpTestFilter.showNotifications: Show notification messages
(default: true)
csharpTestFilter.showDebugOutput: Show debug output in Output panel
(default: false)
csharpTestFilter.buildConfiguration: Build configuration for DLL path -
Debug or Release (default: Debug)
Development
Building from Source
npm install
npm run compile
Debugging the Extension
- Open this project in VS Code
- Press F5 to start Extension Development Host
- The test workspace will automatically load
Project Structure
├── src/
│ └── extension.ts # Main extension logic
├── examples/ # Usage examples and configurations
├── test-workspace/ # Example TUnit project for testing
├── package.json # Extension manifest
└── tsconfig.json # TypeScript configuration
Examples
See the examples directory for:
- Complete
launch.json configurations
- Sample test files with TUnit
- API usage documentation
Support & Feedback
About
Developed by Blue IT Systems GmbH - A German software
development company specializing in custom solutions, DevOps, and digital
transformation.
License
MIT License - see LICENSE file for details.