I am building a test framework using NUnit + SpecFlow + Selenium. I have a solution with two projects(so far). at the top level I have the Suite Framework so: PageFactory, DriverFactory, CommonPages, etc. The other project has the actual tests(cucumber), test steps and test pages. Both projects have the same NuGet packages installed and the second has references to the Suite Framework.
Everything seems to be fine: I have [BeforeTestRun]
, [BeforeScenario]
and [AfterTestRun]
on the framework and when I run the test it is able to find them and execute them but when the code gets to the Cucumber features it just skips them, I mean it highlights them but it does not drill into them.
I checked the steps definitions and they are there (I can go to definition and it does find them no matter in which project they are) and the binding seems to be right. Going to definition Finding the definition
So far this is an example of my code:
feature:In this file the background refers to file placed on the framework project and the scenario to the feature steps inside the same project.
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 steps:
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);
}
}
}
Scenarios steps:
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");
}
}
}
Thanks for your help.