Skip to content

New diagnostic: Remove a common parameter from TestCases #763

@Bartleby2718

Description

@Bartleby2718

Another pet peeve of mine.

[TestCase(1, 42)]
[TestCase(2, 42)]
public void Example(int value1, int value2)
{
    Assert.That(value1, Is.LessThan(value2));
}

can be simplified to

[TestCase(1)]
[TestCase(2)]
public void Example(int value1)
{
    Assert.That(value1, Is.LessThan(42));
}

This reduces an unnecessary variable, helping you focus on what's important. (If you don't want a literal, you can use a const as opposed to a variable.)

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