Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Visual Studio

Visual Studio: Fix Live Unit Testing Marking a Covered Line as Dead

- 24.11.26 - ErcanOPAK

🛠️ 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 .runsettings sets TestAdapterPath, 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.

— Developer Tip

Related posts:

Visual Studio: Supercharge Coding with IntelliCode

Visual Studio: Supercharge Coding with IntelliCode

Visual Studio: Master Code Navigation with Go To

Visual Studio: Master Code Navigation with Go To

Visual Studio: Fix Solution Explorer Ignoring Linked Folder Files

Visual Studio: Fix Solution Explorer Ignoring Linked Folder Files

Views: 10
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

Git: Fix a Shallow Clone Failing to Fetch an Old Tag
WordPress: Fix a Reusable Block Losing Edits After Pattern Sync

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,079 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 868 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 671 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 629 views
  8. 08Average of all values in a column that are not zero in SQL 584 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 561 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com