【问题标题】:How to distinguish between testsuite and testcase on the report如何区分报告上的测试套件和测试用例
【发布时间】:2015-08-13 22:54:48
【问题描述】:

使用 Selenium C# Web 驱动程序和 NUnit 实现自动化。我正在使用命令行生成 Allure 报告,并且我的报告创建得非常好,但我需要以下问题的帮助: 我使用页面对象模型(2 个测试和 1 个页面)具有以下结构。现在,当我看到它显示在顶部测试运行(2 个测试套件,2 个测试用例)的报告时,每个测试用例都是一个测试套件。我想说 1 个测试套件,2 个测试用例。我该怎么做?

namespace ApplicationName.TestCases
{
    [TestFixture]
    class VerifyCreateOrder
    {

        IWebDriver driver;
        [SetUp]
        public void Initialize()
        {
            driver = new FirefoxDriver();
        }

        [TestCase]
        public void doCreateOrder()
        {
            LoginPage loginPage = new LoginPage();
            //some Assertion

         }
    }
}


namespace ApplicationName.TestCases
{
    [TestFixture]
    class SearchOrder
    {

        IWebDriver driver;
        [SetUp]
        public void Initialize()
        {
            driver = new FirefoxDriver();
        }

        [TestCase]
        public void doSearchOrder()
        {
            LoginPage loginPage = new LoginPage();
            //some Assertion

         }
    }
}

以下是我的 LoginPage Page 对象:

namespace ApplicationName.Pages
{
    class LoginPage
    {

        public void doLogin(IWebDriver driver, String username, String password)
        {
            driver.Navigate().GoToUrl("http://www.myxyzsite.com");
            driver.FindElement(By.Id("xyz")).SendKeys(username);
            driver.FindElement(By.Id("xyz")).SendKeys(password); 
            driver.FindElement(By.Id("xyz")).Click(); 

        }
    }
}

我在http://www.nunit.org/index.php?p=suite&r=2.5.5 阅读了有关 NUnit 套件属性的信息,并创建了一个带有枚举器的 c# 类,但我如何调用它/连接它?我需要对我的测试课程进行哪些更改?

namespace NUnit.Tests
{
    public class MyTestSuite
    {
        [Suite]
        public static IEnumerable Suite
        {
            get
            {
                ArrayList suite = new ArrayList();
                suite.Add(new VerifyCreateOrder());
                suite.Add(new SearchOrder());
                return suite;
            }
        }

    }
}

【问题讨论】:

    标签: c# selenium nunit allure


    【解决方案1】:

    我想说 1 个测试套件,2 个测试用例。我该怎么做?

    在不添加套件或类似的情况下,您可以将两个 Test 案例放入同一个 TestFixture,因为这是构建 testsuite 输出的基础。您可以使用部分类来做到这一点,或者您可以简单地将这两个类混为一谈。但是,您的Suite 解决方案是更好的选择。

    我需要对我的测试课程进行哪些更改?

    使用选项 /fixture:NUnit.Tests.MyTestSuite 调用 NUnit。


    请注意,所有这些都随着 NUnit 3 而改变,Suite 属性消失了。除了重新组织你的测试用例之外,我看不出有任何方法可以在 NUnit 3 中做你想做的事情。

    如果将测试合并到套件中非常重要,您可以使用 XSLT。 NUnit 测试结果模式使用 XSLT 非常简单且易于操作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-25
      • 1970-01-01
      • 2013-04-09
      • 2011-10-23
      • 1970-01-01
      • 1970-01-01
      • 2014-09-28
      • 1970-01-01
      相关资源
      最近更新 更多