Skip to content

fix: StringIsNotEmptyAssertion message says 'not empty or whitespace' but only checks IsNullOrEmpty #4871

@thomhurst

Description

@thomhurst

Description

File: TUnit.Assertions/Conditions/StringAssertions.cs (Lines 506-514)

The StringIsNotEmptyAssertion expectation message says "to not be empty or whitespace" but the code only checks !string.IsNullOrEmpty(value). This allows whitespace-only strings like " " to pass.

Impact

Misleading — developers might assume .IsNotEmpty() rejects whitespace strings.

Suggested Fix

Either:

  1. Fix the expectation message to say "to not be null or empty" (matching actual behavior)
  2. Or implement .IsNotNullOrWhitespace() as a separate assertion and fix this one's message

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions