serenity-bdd / serenity-cucumber

Cucumber integration for the Serenity BDD Reporting library
Other
78 stars 74 forks source link

If the Serenity and Cucumber versions are up to date and still this error is faced, : "this class doesn't have an empty or a page enabled constructor".... does it mean a empty constructor is mandatory for stepdefinition classes? #146

Closed UtsaChakraborty closed 6 years ago

UtsaChakraborty commented 6 years ago

I was referring to https://github.com/serenity-bdd/serenity-cucumber/issues/102....but since the POM dependencies are updated , I am unable to understand the reason for the exception. PFB the stepdefinition class: package stepdefinitions;

import cucumber.TestContext; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import net.thucydides.core.annotations.Steps; import pageobjects.StorePage;

import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;

public class StorePageSteps { @Steps TestContext testContext; StorePage storePage;

public StorePageSteps(TestContext context){
    this.testContext = context;
    storePage = testContext.getPageObjectManager().getStorePage();
}

@Given("^: I navigate to the store page$")
public void i_navigate_to_the_store_page() {
    storePage.navigateTo();
}

@When("^: I view the page$")
public void i_view_the_page() {
    assertEquals("Winkel", storePage.getTitle());
}

@Then("^: All mandatory blocks are there$")
public void all_mandatory_blocks_are_there() {
    assertTrue("All assertTrueblocks are present on the store page", storePage.hasTaskMessagesBlock());
    System.out.println("YEah success Should add a check here!");
}

}

UtsaChakraborty commented 6 years ago

Also I am getting , error "package net.thucydides.core.annotations does not exist" while using @Step annotations for Page object files.

wakaleo commented 6 years ago

A step definition file must have an empty constructor to work with Serenity.

qand90 commented 4 years ago

@wakaleo , how to implement shared context then? This was common practice for such cases.

@Inject public StorePageSteps(TestContext context){ this.testContext = context; }