2

Now when Xunit 2.0 is release what is the possibility to run setup/tear down code before and after ALL tests are run? It was not possible in Xunit 1 but according to this xUnit.net - run code once before and after ALL tests there were plans to support that behavior in 2.0.

Community
  • 1
  • 1
Eugene Maksak
  • 41
  • 1
  • 7

2 Answers2

2

It seems like in your case, Collection Fixtures could be helpful. You can find an example in xUnit documentation. In this example, a constructor and a Dispose method of the DatabaseFixture class are places where you can write setup / tear down code. Create a base class for your tests and use this collection fixture for it.

powerz
  • 31
  • 3
2

Here is the AssemblyFixture example published by xUnit, which shows how you can get assembly-level setup and cleanup: https://github.com/xunit/samples.xunit/tree/master/AssemblyFixtureExample

Eugene Maksak
  • 41
  • 1
  • 7