Why is NCover branch coverage 50% even though branch evaluates to both true and false?

605 views Asked by At

In this small piece of code:

public event StabilityChangedHandler StabilityChanged;

267   private void RaiseStabilityChanged()
      {
          if (StabilityChanged != null)
          {
  1           StabilityChanged();
          }
275   }

NCover reports only 50% branch coverage for this Method. However, I know that I RaiseStabilityChanged() is being called with and without handlers being hooked up to the StabilityChangedEvent. On the left I put the hit counts reported by NCover.

Why might NCover be reporting 50% instead of 100%?

1

There are 1 answers

5
therealmitchconnors On

It appears that no test is ever run where StabilityChanged == null. Probably not an important test to run, but it will get your coverage to 100%