VS Code extension
Testy
Rerun only the tests a change can break.
Testy · on save: Calculator.cs
Selected CalculatorTests.cs:
covers Calculator.cs (changed)The problem
Rerunning a whole C# test suite after every save is slow, and choosing which tests to run by hand is guesswork. I built Testy for my own use, to get the continuous feedback of tools like NCrunch inside VS Code: save a file, and see within moments whether the change broke anything.
My contribution
I built the extension in TypeScript with a .NET backend. It runs tests through Microsoft.Testing.Platform, records which source files each test file reaches, and reruns the affected test files when a file is saved. Results appear in VS Code’s Test Explorer, with pass and fail markers on the lines each test covers.
The result
An MIT-licensed extension on the VS Code Marketplace, published for anyone with the same problem. It works with MSTest, xUnit v3, and NUnit on .NET 10 and later, and talks to the test platform directly, so it does not require C# Dev Kit.
A few decisions that shaped it
Fall back when impact cannot be proven
Selection is only useful if it can be trusted. For new files, configuration changes, or missing coverage, Testy runs every test file in the affected project rather than guess.
Keep coverage across partial runs
Each test file keeps its own coverage contribution. Running three files after a save updates those three and leaves the rest of the picture intact.
Explain every selection
Each run records why a test file was chosen, such as the changed file its coverage links to. When a test runs unexpectedly, the reason is one click away.
Under the hood
- Coverage as the dependency map
- During a baseline run, each test file runs separately under coverage. That record of which code a test file executed, down to individual method bodies, is what later narrows a save to the tests that matter.
- A compiler check for what coverage misses
- Changes to constants, signatures, and attributes can affect code without appearing in runtime coverage. A Roslyn analyzer catches those declaration changes and widens the selection.
- Saves do not throw work away
- When a save arrives during a run, test files already running are allowed to finish unless the change affects all of them, and the next run does not repeat them.
Have a project in mind? Let’s talk