SpecFlow找到了步骤定义,但没有执行它们

我正在使用NUnit + SpecFlow + Selenium构建测试框架。我有两个项目的解决方案(到目前为止)。在顶层,我具有Suite框架:PageFactory,DriverFactory,CommonPages等。另一个项目具有实际的测试(黄瓜),测试步骤和测试页。 两个项目都安装了相同的NuGet软件包,第二个项目引用了Suite Framework。

一切似乎都很好:我在框架上有[BeforeTestRun][BeforeScenario][AfterTestRun],当我运行测试时,它能够找到并执行它们,但是当代码进入Cucumber功能,只是跳过了它们,我的意思是突出显示了它们,但没有深入研究它们。

我检查了步骤定义,并且它们在那里(我可以转到定义,无论它们在哪个项目中,它都可以找到它们),并且绑定似乎是正确的。 Going to definition Finding the definition

到目前为止,这是我的代码示例:

功能:在此文件中,背景是指放置在框架项目上的文件,而场景是指同一项目内的功能步骤。

Feature: Reports
    As an admin
    I want to access to the Reports
    So I can see the information related to my product

Background: 
    When I navigate to the 'Reports' page
    And I navigate to my product reports

@Regression
Scenario: I can open the report
    When I click on the 'overall' tile
    Then the report is displayed
    And the data matches the database

Backgorund步骤:

using UI.Suite.CommonPages.Pages;
using OpenQA.Selenium;
using TechTalk.SpecFlow;

namespace UI.Suite.CommonPages.Steps
{
    [Binding]
    public class SideBarNavigation
    {
        private readonly SideMenuComponent sideMenuComponent;

        public SideBarNavigation(IWebDriver driver)
        {
            sideMenuComponent = new SideMenuComponent(driver);
        }

        [When(@"I navigate to the '(.*)' page")]
        public void NavigateTo(string page)
        {
            sideMenuComponent.SideMenuNavigation(page);
        }
    }
}

场景步骤:

using NUnit.Framework;
using TechTalk.SpecFlow;
using UI.Products.Tests.Pages;
using OpenQA.Selenium;

namespace UI.Products.Tests.Steps
{
    [Binding]
    public class ReportsSteps
    {
        private readonly ReportsPage _reports;

        public ReportsSteps(IWebDriver driver)
        {
            _reports = new ReportsPage(driver);
        }

        [When(@"I navigate to my product reports")]
        public void WhenINavigateToMyProducts()
        {
            _reports.SelectMyProduct();
        }

        [When(@"I click on the '(.*)' tile")]
        public void WhenIClickOnAGivenReport(string report)
        {
            _reports.SelectReportTileAndConfig(report);
        }

        [Then(@"the report is displayed")]
        public void TheReportDisplays()
        {
            Assert.IsTrue(_reports.HasReportLoaded(),"The report has not loaded correctly");
        }

        [Then(@"the data matches the database")]
        public void TheDataDisplays()
        {
            Assert.IsTrue(_reports.DoesUIMatchDB(),"The data on the database does not match the UI");
        }
    }
}

感谢您的帮助。

Asongze123456789 回答:SpecFlow找到了步骤定义,但没有执行它们

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2991737.html

大家都在问