Controlling execution order of unit tests in Visual Studio

前端 未结 9 1822
情歌与酒
情歌与酒 2020-11-27 15:44

Okay, I\'m done searching for good information on this. I have a series of Unit Tests that call a static class which, once initialized, sets properties that cannot (or I don

9条回答
  •  臣服心动
    2020-11-27 15:59

    Merge your tests into one giant test will work. To make the test method more readable, you can do something like

    [TestMethod]
    public void MyIntegratonTestLikeUnitTest()
    {
        AssertScenarioA();
    
        AssertScenarioB();
    
        ....
    }
    
    private void AssertScenarioA()
    {
         // Assert
    }
    
    private void AssertScenarioB()
    {
         // Assert
    }
    

    Actually the issue you have suggests you probably should improve the testability of the implementation.

提交回复
热议问题