【问题标题】:Parameterized test using nunit3-console.exe with TestCase attribute使用带有 TestCase 属性的 nunit3-console.exe 进行参数化测试
【发布时间】:2017-07-11 21:40:15
【问题描述】:

我正在尝试使用 TestCase 属性运行 nunit3 参数化测试。

我的测试方法如下:

[Test]
        [TestCase("testuser")]
        public void OBA_Test(String name)
        {
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10000));
            driver.Navigate().GoToUrl(baseURL + somewebsite)
            // Code to test website. 
        }

然后我获取 dll 并尝试使用

运行
nunit3-console.exe "C:\temp\test\Selenium Testing Prod.dll" /run:"SeleniumTests.SeleniunProdTest.OBA_Test(\"testuser\")"

我在这里做错了什么?任何指针?

参考:nunit-console does not run tests parameterized with TestCase attribute

【问题讨论】:

    标签: c# .net unit-testing nunit nunit-console


    【解决方案1】:

    该消息告诉您,您正在使用的 NUnit 版本无法识别 /run 选项。 NUnit V2 的 /run 被 NUnit 3 中增强的 /test 选项取代。

    【讨论】:

    • 抱歉延迟回复。我使用了 Nunit3,一切都很好。我使用 TestContext.Parameters.Get("variable") 从命令行获取输入,然后使用 --params。我接受您的回复作为解决方案,并将发布我的解决方案。
    【解决方案2】:

    我使用的是 nunit 版本 2,它缺少一些功能。我更新到第 3 版并遵循这篇文章: http://executeautomation.com/blog/passing-parameters-to-nunit-test-via-cli-using-params/

    基本上在我的 [Setup] 中,我将命令行输入收集为:

    name = TestContext.Parameters.Get("empname");
    

    并在我的 [Test] 中使用它并在命令行中使用 --params 如下:

    nunit3-console.exe --params:empname=testemp "C:\temp\Debug_PROD\Selenium Testing Prod.dll"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多