如果测试有,SetUp 和 TearDown 方法是否需要 [RequiresSTA]? [英] Do the SetUp and TearDown methods need [RequiresSTA] if tests have it?

查看:69
本文介绍了如果测试有,SetUp 和 TearDown 方法是否需要 [RequiresSTA]?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以毫无问题地使用 ReSharper 运行我的 WatiN 测试.每个测试都有 RequiresSTA 属性并且运行良好.

I can run my WatiN tests with ReSharper without issues. Each test has the RequiresSTA attribute and runs fine.

当我尝试运行类 (TestFixture) 中的所有测试时,出现以下错误:

When I try run all the tests in the class (TestFixture) I get the following error:

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

该错误并未表明我需要更改什么才能使其正常工作.

The error doesn't indicate what I need to change to make it work.

如果我在单元测试会话"窗口中选择所有被忽略的测试,我可以毫无问题地运行它们.

If I then select all the tests that have been ignored in the Unit Test Sessions window, I can run them without problems.

我必须更改哪些内容才能运行 TestFixture 中的所有测试?

What must I change to allow me to run all the tests in the TestFixture?

推荐答案

我遇到了同样的问题.我将 SetUp() 和 TearDown() 方法更改为公共方法,然后它就起作用了.

I have met the same problem. I changed SetUp() and TearDown() methods to be public, then it worked.

这篇关于如果测试有,SetUp 和 TearDown 方法是否需要 [RequiresSTA]?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆