🛠️ Visual Studio: Fix Live Unit Testing Marking a Covered Line as Dead
Live Unit Testing colors every line in the editor gutter red, green, or blue by continuously re-running whichever tests it has discovered are affected by your last edit, but that coverage picture is only ever as complete as the set of test projects it actually knows about. A test project added to the solution after Live Unit Testing was already running, or one whose runsettings point at a TestAdapterPath Live Unit Testing never indexed, contributes nothing to that live coverage map, so any production line reachable only through that project’s tests renders as uncovered dead code in the gutter even while a normal Test Explorer run exercises it completely.
🔎 The Problem
// Added after Live Unit Testing was already running:
// Tests.Integration.csproj
[TestClass]
public class OrderPipelineTests
{
[TestMethod]
public void ProcessBatch_SkipsVoidedOrders()
{
// This test genuinely covers OrderPipeline.ProcessBatch,
// but Live Unit Testing never rebuilt its project baseline
// to include Tests.Integration, so the covered line still
// shows a gray 'not covered' mark in the editor gutter.
}
}
✅ Fix: Make Live Unit Testing Re-Discover the New Project
- Stop and restart Live Unit Testing (Test > Live Unit Testing > Reset) any time a new test project is added to the solution, since it builds its coverage baseline once at startup and does not automatically rescan for newly added projects.
- Open the Live Unit Testing coverage tool window and confirm the new project actually appears in its included-projects list before trusting any gutter mark it produces for code that project exercises.
- If a custom
.runsettingssetsTestAdapterPath, check that the same path is reachable from Live Unit Testing’s own settings, since it reads test discovery configuration independently of a plain Test Explorer run.
🚨 Why This Is Dangerous
- A gray ‘not covered’ mark that’s really just an invisible project to Live Unit Testing can read as proof a line is dead code, and deleting it on that basis removes logic a real integration test suite depends on.
Live Unit Testing’s gutter colors are only as complete as the project list it’s watching — a project it never saw run can leave real coverage looking like dead code.




