Skip to content

MSTest v4 TestContext properties should not be nullable #1403

@Mertsch

Description

@Mertsch

Describe the bug

MSTest 3.0.0-preview-20221122-01
TestContext.TestName is nullable, which is technically correct, but makes no sense to me.

Expected behavior

"All" (those which make sense) Properties of TestContext should not be nullable and throw an exception if the underlying property dictionary has those properties removed or replaced by nulls.

Example:
public virtual string TestName => GetProperty<string>("TestName") ?? throw new InvalidOperationException("Missing TestName");

Having nullable on all those properties just makes tests much more verbose. And when I expect a TestRunDirectory, havin null there is an exceptional case anyway. Plus if I really needed an optional TestRunDirectory I could retrieve it via GetProperty().

Actual behavior

public virtual string? TestName => GetProperty<string>("TestName");

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: MSTestIssues with MSTest that are not specific to more refined area (e.g. analyzers or assertions)Breaking ‼️In-PR

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions