2013-07-11 35 views
5

我可以用ReSharper運行我的WatiN測試,沒有問題。每個測試都有RequiresSTA屬性並且運行正常。如果測試有SetUp和TearDown方法,需要[RequiresSTA]嗎?

當我嘗試運行的類(的TestFixture)我得到以下錯誤的所有測試:

One or more child tests had errors 
Exception doesn't have a stacktrace 
<testname> ignored: Invalid signature for SetUp or TearDown method: TestSetup 
<testname> ignored: Invalid signature for SetUp or TearDown method: TestSetup 
<testname> ignored: Invalid signature for SetUp or TearDown method: TestSetup 

的錯誤並不表示什麼,我需要改變,使其工作。

如果我然後選擇在單元測試會話窗口中被忽略的所有測試,我可以毫無問題地運行它們。

爲了讓我能夠運行TestFixture中的所有測試,我必須做些什麼?

回答

18

我遇到了同樣的問題。我改變了SetUp()和TearDown()方法以公開,然後工作。

+1

這似乎也是ReSharper 9中的一個問題,即同樣的解決方案似乎可以解決。 –

+0

'protected'也可以。 –

0

我一直在我的解決方案的App.config文件中設置公寓狀態,NUnit GUI runner按預期運行整個設備。

App.config就像這樣開始。

<?xml version="1.0"?> 
<configuration> 
    <configSections> 
    <sectionGroup name="NUnit"> 
     <section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/> 
    </sectionGroup> 
    </configSections> 
    <NUnit> 
    <TestRunner> 
     <!-- Valid values are STA,MTA. Others ignored. --> 
     <add key="ApartmentState" value="STA"/> 
    </TestRunner> 
    </NUnit> 
    <appSettings> 
........ 

編輯:我使用的是Watin2.1和NUnit 2.5。

相關問題