Using WPF components in NUnit tests - how to use STA?

Solution 1:

You should add the RequiresSTA attribut to your test class.

[TestFixture, RequiresSTA]
public class MyTestClass
{
}

Solution 2:

With more recent versions, the attribute has changed :

[Apartment(ApartmentState.STA)]
public class MyTestClass
{}