Reputation: 41
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.
Upvotes: 2
Views: 8628
Reputation: 41
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
Upvotes: 2
Reputation: 41
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.
Upvotes: 2