在诱惑报告Nunit3中添加身体测试步骤

问题描述 投票:0回答:1

我写了一个简单的NUnit3测试类,我想为它生成一个诱惑报告。

[TestFixture]
[AllureNUnit]
public class SampleAllureTest
{
    [OneTimeSetUp]
    public void SetUp()
    {
         CreateDatabase();               
    }

    [OneTimeTearDown]
    public void CleanUp()
    {
        DropDatabase();
    }

    [Test]
    [AllureSeverity(SeverityLevel.critical)]
    public void CreateHierarchy()
    {
         // first step
         // second step
         // third step
    }
}

我已经执行了我的测试。在那之后,我在本地运行一个命令来生成诱惑报告。

allure serve .\allure-results\

我的报告准备好了。

在浏览器中打开它并查看“套件”选项卡以获取有关我的测试的详细信息。它看起来像here

我如何向倾向报告中显示的正文添加其他描述步骤。

我希望看到像from demo allure report这样的东西,其中打开的小部件页面测试在体内有一些步骤。

c# allure
1个回答
0
投票

它可以通过函数AllureLifecycle.Instance.WrapInStepfrom allure examples)实现

[Test]
[AllureSeverity(SeverityLevel.critical)]
public void CreateHierarchy()
{
     AllureLifecycle.Instance.WrapInStep(() =>
     {
     // first step
     }, "first step");
     AllureLifecycle.Instance.WrapInStep(() =>
     {
        // second step
     }, "second step");
     AllureLifecycle.Instance.WrapInStep(() =>
     {
        // third step
     }, "third step");
}

我们只是包装一些测试代码并为它们设置名称。

© www.soinside.com 2019 - 2024. All rights reserved.