Namespce OneTimeTearDownAttirbute()和OneTimeSetUpttirbute()在NUnit.Framework中不存在,显示自动生成的specflow(.cs)文件中的错误

时间:2019-05-31 10:22:15

标签: nunit specflow xamarin.uitest

面对构建错误类型或名称空间名称“ OneTimeSetUpAttribute”和“ OneTimeTearDownAttribute”不存在

Xamarin.UITest版本3.0.0 Nunit-版本2.6.4 NunitTestAdapter-版本2.0.0 Specflow-版本2.1.0.0 enter image description here

3 个答案:

答案 0 :(得分:1)

OneTimeSetUpAttribute存在于NUnit 2.6.5中,可以在这里找到文档:http://nunitsoftware.com/nunitv2/index.php?p=onetimeSetUp&r=2.6.5

因此,您可以尝试做的第一件事就是更新NUnit NuGet软件包。 如果您使用的是SpecFlow,则编辑SpecFlow生成的文件将无济于事,因为它们将由SpecFlow再次重新生成。

最好的办法是开始使用新的NUnit 3.x和新的SpecFlow软件包。

答案 1 :(得分:0)

OneTimeSetUpAttribute直到NUnit 3.0才存在。相反,您想使用TestFixtureSetUpAttribute

您可以在这里找到NUnit 2.6.4的文档:http://nunit.org/docs/2.6.4/docHome.html

答案 2 :(得分:0)

在NUnit 2.6.4中,SetUpFixture使用了SetUpAttributeTearDownAttribute。在NUnit 3中,这已更改为OneTimeSetUpAttributeOneTimeTearDownAttribute。@ Chris所指的hange也发生了,但它影响TestFixture而不是SetUpFixture