NUnit - cleanup after test failure

后端 未结 11 953
盖世英雄少女心
盖世英雄少女心 2020-12-24 05:09

We have some NUnit tests that access the database. When one of them fails it can leave database in inconsistent state - which is not an issue, since we rebuild database for

11条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-24 05:52

    What about using a Try-Catch block, rethrowing the exception caught?

    try
    {
    //Some assertion
    }
    catch
    {
         CleanUpMethod();
         throw;
    }
    

提交回复
热议问题