It is incorrect by design to have async call within TestInitialize, as TestInitialize has to happen before any TestMethod and have fixed signature.
Can this be correct approach in any way to have async TestInitialize as well?
private int val = 0;
[TestInitialize]
public async Task TestMehod1()
{
var result = await LongRunningMethod();
val = 10;
}
[TestMethod]
public void TestMehod2()
{
Assert.AreEqual(10, val);
}
Any thoughts?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…