Running Tests in Single Threaded Apartment
James <[email protected]>
| Newsgroups | gmane.comp.windows.dotnet.nunit.user |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I am having trouble getting NUnit to run my tests in a single threaded
apartment model thread.
I have a class:
<TestFixture()> _
Public Class FormManagerTest
<TestFixtureSetUp()> _
Sub TestFixtureSetUp()
Assert.AreEqual(System.Threading.Thread.CurrentThread.GetApartmentState,
System.Threading.ApartmentState.STA, _
"Threading Apartment State must be Set to STA for COM
Object to Operate Properly")
End Sub
...
End Class
In a project UnitTests. This unit test always fails as the apartment
model is set to MTA. I have a config file UnitTests.dll.config (which
has Copy to Output Directory: Copy Always), it exists in the same dir
as nunit gui runner is pointed to which from what I read should cause
the tests to be run in an STA thread.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="NUnit">
<section name="TestRunner"
type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
<NUnit>
<TestRunner>
<add key="ApartmentState" value="STA" />
</TestRunner>
</NUnit>
</configuration>
I found some references to a /thread argument for nunit.exe but I
think that is old as when I supply it it gives me an error. I've
found a few references online but they seem to be using older versions
and the suggestions don't seem to work.
Any help would be appreciated. Thank you.
James Thigpen
JMT Systems
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/