Skip to content

Isolate every test cases that are in a single test method #1

Open
@walterlv

Description

@walterlv

The test cases in a single test method may capture common variables in the method header. So a test case may affect each other.

public void Foo()
{
    var a = 1;

    "Test case 1".Test(() =>
    {
        a++;
        Assert.AreEqual(a, 2);
    });

    "Test case 2".Test(() =>
    {
        a++;
        Assert.AreEqual(a, 2);
    });
}

I recommend isolating every test cases that are in a single test method.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions