【问题标题】:How do you migrate ExpectedException's syntax from NUnit 2.2.9 to 2.6.3如何将 ExpectedException 的语法从 NUnit 2.2.9 迁移到 2.6.3
【发布时间】:2014-10-28 18:24:35
【问题描述】:

在使用 NUnit 2.2.9 的旧代码中,ExpectedException 如下所示:

<Test(), ExpectedException(GetType(System.Exception), "ExpectedErrorMessage")> Public Sub TestCase
    ' Some test case
End Sub

根据最终提供此答案的一些研究,https://stackoverflow.com/a/268313/456645,我有这个:

<Test(), ExpectedException(GetType(System.Exception), ExpectedMessage = "ExpectedErrorMessage")>

这会产生错误:未声明“ExpectedMessage”。由于其保护级别,它可能无法访问。

我正在使用 NUnit 2.6.3.13283 并像这样导入它:Imports NUnit.Framework

【问题讨论】:

标签: vb.net nunit


【解决方案1】:

访问命名参数的语法错误。在 VB.Net 中应该是这样的:

<Test(), ExpectedException(GetType(System.Exception), ExpectedMessage:="asdf")>

Passing Arguments by Position and by Name (Visual Basic)

【讨论】:

    猜你喜欢
    • 2018-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-07
    • 1970-01-01
    • 2016-04-09
    相关资源
    最近更新 更多