Skip to content

AssertionScope.AddNonReportable still reports the value in the failure message #1599

@eNeRGy164

Description

@eNeRGy164

When looking for code coverage, found some noncovered code and writing a unit test for it gave a surprising behavior.

If I did not understand the functionality, and the behavior is actually correct, please close this issue.

Description

AssertionScope.AddNonReportable still reports the value in the failure message.

According to the documentation:

Tracks a keyed object in the current scope that is excluded from the failure message in case an assertion fails.

Complete minimal example reproducing the issue

[Fact]
public void When_using_non_reportable_value_it_should_not_be_replaced_with_context()
{
    // Arrange
    var scope = new AssertionScope();
    scope.AddNonReportable("SomeKey", "SomeValue");

    AssertionScope.Current.FailWith("{SomeKey}");

    // Act
    Action act = scope.Dispose;

    // Assert
    act.Should().ThrowExactly<XunitException>()
        .Which.Message.Should().NotContain("SomeValue");
}

Expected behavior:

The message should not replace "{SomeKey}".

Actual behavior:

It is replaced.

Versions

  • 6.0 beta 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions