Skip to content

Unit test coverage for the PropertyGrid class #12055

Closed as not planned
Closed as not planned

Description

@LeafShi1

Currently the unit test coverage of the PropertyGrid is 49.91%

image

The following code lacks unit test coverage. For details, please refer to Code Coverage

The code line under Constructor:

  • if (ScaleHelper.IsThreadPerMonitorV2Aware)
  • catch (Exception ex) when (!ex.IsCriticalException())

Functions:

Properties:

  • ActiveDesigner if (_rootEntry is not null)
  • CanCopy
  • CanCut
  • CanPaste
  • CanUndo
  • CommandsVisibleIfAvailable if (hotcommandsVisible != _commandsPane.Visible)
  • FreezePainting get => _paintFrozen > 0;
  • GridViewVisible
  • PropertySort if (selectedGridItem is not null)
  • SelectedObjects Set method
  • SortedByCategories
  • ToolStripRenderer Get method
  • IComPropertyBrowser.ComComponentNameChanged
  • PropertyTabChanged Remove method
  • SelectedGridItemChanged Remove method
  • InPropertySet
  • UseCompatibleTextRendering Set method

Activity

  1. changed the title [-]The missed test of the PropertyGrid.cs[/-] [+]Unit test coverage for the PropertyGrid class[/+] on Sep 5, 2024
  2. added
    test-bug
    on Sep 5, 2024
  3. added this to the .NET 10.0 milestone on Sep 5, 2024
  4. modified the milestones: .NET 10.0, .NET 11 on Feb 18, 2026
  5. added a commit that references this issue on Jun 10, 2026
  6. LeafShi1 commented on Jun 11, 2026

    @LeafShi1
    MemberAuthor

    After reviewing the current progress on increasing test coverage for PropertyGrid (issue #12055), I believe this issue can be closed or should be re-scoped.

    The original goal of this issue is to improve unit test coverage. However, many of the remaining uncovered areas are private or internal methods. Adding tests directly targeting these methods introduces several concerns:

    1. Fragility and tight coupling
      Tests that directly invoke private or internal implementation details are inherently fragile and tightly coupled to the current code structure. Any refactoring (even without behavioral changes) can easily break these tests.

    2. Limited value for product correctness
      Private methods do not represent user-observable behavior. As seen in previous cases, a private method can contain defects but remain unobservable if it is not used or does not affect public behavior. In such cases, additional tests do not improve product reliability.

    3. Existing repo guidance and reviews
      Prior reviews and guidelines in this repository emphasize testing observable behavior through public APIs rather than testing implementation details directly. In several cases, tests targeting internal/private paths were considered redundant when public behavior was already covered.

    Given the above, further work on this issue would likely result in low-value or brittle tests. Instead, future efforts should focus on:

    • Verifying observable behavior through public APIs
    • Covering complex or high-risk execution paths
    • Adding regression tests for real user-facing bugs

    Based on this, I closed this issue .

  7. locked and limited conversation to collaborators on Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

test-bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions