How to run setup code only once in an xUnit.net test

前端 未结 3 1201
我在风中等你
我在风中等你 2020-12-29 22:17

I\'m trying to setup my tests using Xunit. I have a requirement to delete all images in a folder start of the tests, and then each method does some image resizing and saves

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-29 23:02

    The old IUseFixture interface in xUnit.net v1.x has been replaced by two new interfaces: IClassFixture and ICollectionFixture. In addition, the mechanism for injecting fixture values into your tests has changed from property setters to constructor arguments. Class fixtures are created once and shared amongst all tests in the same class (much like the old IUseFixture). Collection fixtures work the same way, except that the single instance is shared amongst all tests in the same test collection.

提交回复
热议问题