Question

Im trying to get our specflow watin tests to run on our new teamcity server. The problem is that I cant get the built in nunit runner to run tests in appartmentstate STA.

We used this configuration earlier, which works with other testrunners:

<NUnit>
    <TestRunner>
        <add key="ApartmentState" value="STA" />
    </TestRunner>
</NUnit>

But the TeamCity NUnit test runner doesnt seem to pick up on this config. We have other config sanity tests in place, so we know the testrunner reads the configuration for our test project atleast.

There's the alternative to use the RequiresSTA attribute like so:

[Test, RequiresSTA]
public void ShouldRunThreadApartmentStateSTAWith()
{
  Assert.AreEqual(ApartmentState.STA, Thread.CurrentThread.GetApartmentState());
}

But since the NUnit tests are generated by SpecFlow, I don't have control over how these attributes are set.

How can I get this setup to work?

Was it helpful?

Solution 2

Found the answer.

Setting the RequireSTA attribute in AssemblyInfo.cs makes the configuration obsolete.

[assembly:RequiresSTA]

OTHER TIPS

The NUnit tests generated by SpecFlow is a partial class definition, so simply create another partial class definition in another file that has the attributes on it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top