serenity-bdd / serenity-cucumber

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

Tests passing but show as pending in the log and the report #71

Closed mohammedalnuaimi closed 7 years ago

mohammedalnuaimi commented 8 years ago

Hi there, I have been trying to figure out why the test keep showing as pending whereas it is passing in Intellij, but it shows as pending when running it with Maven and also shows pending in Serenity Report site. I have my project organised as follows: Feature file example

Feature: Client should get the portfolio of the sky customer returned

In order to see the customer portfolio As a client I want to get the customer portfolio

Scenario: client gets customer portfolio When the client gets the getPortfolio api using Id pid-xxxxxxxxxxxxxxxx Then assert the profile result And print out the results

Here I will just show part of the file, one step definition to demonstrate what am doing

package serenity.test.suite.steps.steps.services;

import cucumber.api.java.Before; import cucumber.api.java.en.And; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import net.thucydides.core.annotations.Steps; import serenity.test.suite.steps.serenity.services.; public class getPortfolio { @Steps profileSteps profileClass; @When("^the client gets the getPortfolio api using Id (.)$") public void the_client_gets_the_getPortfolio_api_using_Id_pid(String Id) //throws Throwable { profileClass.getProfileResponse(Id); } }

Then the step definition method "getProfileResponse" will call some other code located in other class under the serenity package

It's really confusing, it keep telling me the method is not implemented however it is clearly implemented and passing when I run it. However when I run it with Maven I get the below:

Tests run: 6, Failures: 0, Errors: 0, Skipped: 5, Time elapsed: 0.031 sec - in serenity.test.suite.steps.TestRunners.RunProductTests Running serenity.test.suite.steps.TestRunners.RunServiceTests

1 Scenarios (1 undefined) 3 Steps (3 undefined) 0m0.000s

You can implement missing steps with the snippets below:

@When("^the client gets the getPortfolio api using Id pid-(\d+)$") public void the_client_gets_the_getPortfolio_api_using_Id_pid(int arg1) throws Throwable { // Write code here that turns the phrase above into concrete actions throw new PendingException(); }

I would appreciate your assistance Many thanks

mohammedalnuaimi commented 7 years ago

Any idea?

wakaleo commented 7 years ago

Cucumber is not matching your step definitions to the feature files. You need to tell Cucumber where to find the step definitions if they are not in or under the package of the test runner, using the glue option, e.g:

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features = "src/test/resources/features/find_taxi_ranks/find_taxi_stands_by_proximity.feature",
        glue = "net.serenitybdd.demos.taxiranks")
public class FindTaxiRanks {
}
mohammedalnuaimi commented 7 years ago

Thanks wakaleo for your response, yes this solved the it cheers Mohammed