Xunit: What is the appropriate place to run setup /teardown code before and after all test collections have been executed?

Created on 3 Oct 2017  路  3Comments  路  Source: xunit/xunit

We are trying to create some resources (e.g. a database table), and later delete them after running multiple test collections.
We don't want to create and delete them for *every collection*

We tried overriding the Dispose method of the assembly runner with mixed results. This seems to work in Visual studio, but when running it from the VSTS task "Visual Studio Test" it seems as if the dispose method never gets called, which makes us think that the vstest.console.exe might shut down /timeout before calling our teardown code.

Is there another recommended approach?

Most helpful comment

We do not officially support assembly-level fixtures in the box, but we have a sample that illustrates how to do it: https://github.com/xunit/samples.xunit/tree/master/AssemblyFixtureExample

All 3 comments

We do not officially support assembly-level fixtures in the box, but we have a sample that illustrates how to do it: https://github.com/xunit/samples.xunit/tree/master/AssemblyFixtureExample

Looks promising! BeforeTestAssemblyFinishedAsync is exactly what I was looking for, Ill refactor my project and verify that this resolves my issues in VSTS as well. Will report back here ASAP!

I can confirm that this approach solved my issue!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattscheffer picture mattscheffer  路  4Comments

roji picture roji  路  4Comments

ghost picture ghost  路  4Comments

bradwilson picture bradwilson  路  3Comments

jonparky picture jonparky  路  3Comments