Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
walterlv opened this issue Feb 28, 2018 · 0 comments
Open

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

walterlv opened this issue Feb 28, 2018 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@walterlv
Copy link
Member

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.

@walterlv walterlv added the enhancement New feature or request label Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants