how to globally enforce of STA in NUnit 2.6 ?

Asked by Piotr Dudała

Hello,

Is there any way that allows global enforement of STA in NUnit 2.6 ?

I recently read that NUnit no longer recognizes settings regarding Single/Multiple Thread Apartment from configuration files.
Presently I'm working on what I think is pretty common setup (C#, NUnit,SpecFlow,Selenium2 and hundreds of scenarios spread among few sepearate projects in one solution.). I have chosen NUnit mainly because of standalone runner. After conversion from Microsoft Test Framework and subsequent upgrade to NUnit 2.6 standalone runner reports error in every scenario, saying basically that tests should run in STA mode. File,where it complains about it are all generated by SpecFlow which can hardly be pressed to put additional attributes in it's generated code...

Could someone suggest a way to remedy this, as I'd like to leave this test suite to be a bit more future-proof, not bound to 2.5.x line... ?

Best Regards,
Piotr

Question information

Language:
English Edit question
Status:
Solved
For:
NUnit V2 Edit question
Assignee:
No assignee Edit question
Solved by:
Piotr Dudała
Solved:
Last query:
Last reply:
Revision history for this message
Charlie Poole (charlie.poole) said :
#1

The "standard" approach would be to use an assembly-level
RequiresSTAAttribute to run under the STA. You could put the attribute
in a separate file to be included in the project with all the
generated files.

An alternative - assuming you use the console runner - is to use the
/apartment=STA option on the command line.

For the gui runner, a quick feature request might get the change into
NUnit 2.6.1, which just dropped it's RC.

Charlie

On Tue, Jul 10, 2012 at 2:35 PM, Piotr Dudała
<email address hidden> wrote:
> New question #202776 on NUnit Framework:
> https://answers.launchpad.net/nunit-3.0/+question/202776
>
> Hello,
>
> Is there any way that allows global enforement of STA in NUnit 2.6 ?
>
> I recently read that NUnit no longer recognizes settings regarding Single/Multiple Thread Apartment from configuration files.
> Presently I'm working on what I think is pretty common setup (C#, NUnit,SpecFlow,Selenium2 and hundreds of scenarios spread among few sepearate projects in one solution.). I have chosen NUnit mainly because of standalone runner. After conversion from Microsoft Test Framework and subsequent upgrade to NUnit 2.6 standalone runner reports error in every scenario, saying basically that tests should run in STA mode. File,where it complains about it are all generated by SpecFlow which can hardly be pressed to put additional attributes in it's generated code...
>
> Could someone suggest a way to remedy this, as I'd like to leave this test suite to be a bit more future-proof, not bound to 2.5.x line... ?
>
> Best Regards,
> Piotr
>
>
>
>
> --
> You received this question notification because you are a member of
> NUnit Core Developers, which is an answer contact for NUnit Framework.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~nunit-core
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~nunit-core
> More help : https://help.launchpad.net/ListHelp

Revision history for this message
Piotr Dudała (piotr-dudala) said :
#2

Charlie, thank you very much for quick answer.
I still have some problem in introducing the attribute on assembly level (I don't think it's beeing recognized or it looks like it's being 'lost in the build) so I'll be sending change request shortly. Still, I mark problem as solved. Thanks !