1

Closed

(MSTest) AssemblyInitialize equivlent?

description

IUseFixture<T> is the equivalent of SetupFixture in NUnit and ClassInitialize in MSTest. Well, that's not entirely true because in NUnit, If you declare SetUpFixture outside of the namespace in which the tests run, it then will act as setup for the assembly. I would know becuase I had an assembly where I could toggle between MSTest and NUnit freely by giving using aliases such as:

if MSTEST

using AssemblyInitialize = NUnit.Framework.SetUpFixtureAttribute;

So how can I get IUseFixture<T> to allow me to share context between all tests in an assembly, not just a class? Is there some other feature of XUnit that will let me do this that I missed?
Closed May 5, 2013 at 1:05 AM by BradWilson
We will support this at the test collection level in v2. We are not planning to do any assembly-wide setup and teardown.

comments

Togakangaroo wrote Dec 11, 2012 at 3:40 PM

Seconded. I realize this goes against the standard unit-testing grain but it's just a matter of being practical.

I have selenium tests so ideally on assembly load I would like to start up iisexpress and on assmebly unload I'd like to shut it down. Doing this on every single test greatly increases the execution time and is simply not practical.

BradWilson wrote Dec 14, 2012 at 12:26 AM

There is no equivalent today.

justinc wrote Dec 15, 2012 at 3:05 PM

Can you just put it into a static constructor?

BradWilson wrote Dec 16, 2012 at 2:57 AM

You can't predict when static constructors are run (only that they have run before you can touch any static members).

There would be no cleanup equivalent, using a static constructor.

RhysC wrote Mar 15, 2013 at 2:28 AM

I'm in the same boat as Togakangaroo, would like to use xunit as it it s what we are using for our unit tests, however not having an assembly wide init makes this difficult (specifically for selenium based tests)