Skip to content

Looking for help with upgrade to 3.9 - TestInitialize changed? #5641

@davesmits

Description

@davesmits

Describe the bug

I am trying to upgrade to MSTest. This are the package changes I am now making
Image

after upgrading some tests start to fail; it almost feels like objects created in the TestInitialize are not matched up with the right test (as if i get different variable values).

example

private Mock<MyObject> _mock;
[TestInitialize]
public async Task Initialize()
{
await Task.Delay(100); // just for demo
_mock = new Mock<MyObject>();
}

[TestMethod]
public async Taks ExecuteTestAsync()
{
_mock.Object.DoSomething();
}

When running my test the results are everything different with verifying the number of method invocations; Sometimes too much, sometimes not enough; but never consisted. When I add DoNotParallize it's already more stable but still 'random' results while these problems didnt exist before 3.9

Looking for some advice how to further diagnose this.

Steps To Reproduce

Looking for help to understand how to debug this?

Expected behavior

Test showing same before as version 3.8.3

Actual behavior

Test are flaky and unpredictable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: MSTestIssues with MSTest that are not specific to more refined area (e.g. analyzers or assertions)Needs: Additional Info

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions