While trying to create unit tests for view models (using the Model-View-ViewModel pattern), I came across a problem while trying to execute unit tests from NUnit. The error I recevied was:
The calling thread must be STA, because many UI components require this.
A quick search on Google yielded an answer.
However, the configuration file in the post was incorrect and was noted by a commentor. For expediency, I have included the correct configuration text below:
<
configSections>
<sectionGroup name="NUnit">
<section type="System.Configuration.NameValueSectionHandler" name="TestRunner"></section>
</sectionGroup>
</configSections>
<
NUnit>
<TestRunner>
<add value="STA" key="ApartmentState"></add>
</TestRunner>
</NUnit>