-4

I am doing UI testing in JAVA selenium cucumber environment How can I make the status of a test PENDING deliberately? Now I get FAILED and PASSED. I need this feature temporarily, I know tests should only pass or fail and it's not a good choice to have other options. (I don't want to make any configurations in jenkins.)

Thank you

Xovika
  • 158
  • 1
  • 6
  • Could you add more details to your question? Where do you want this status? In some Jenkins pipeline, in cucumber report,...? Also, if status for test is "PENDING" then logically whole pipeline or test suite or whatever is in "PENDING" status as well. What is the purpose of this? – Sergei Sirik Apr 18 '18 at 21:10
  • Why do you need to have 'pending' status? If the goal is not to execute some features/scenarios for some reason - you could use tags in cucumber. Ex.: "@"wip (work in process), "@"ignore etc. (they could be used on feature level or scenario level). P.S.: You should remove the " – Mr Cas Apr 19 '18 at 08:59

1 Answers1

2

You can throw the cucumber.api.PendingException from the matching stepdefinition method. This will show up the scenario as pending. For getting these pending stepdefinition easily use dryRun=true in the cucumberoptions of the runner.

For the below feature file.

  Scenario: Run Pending scenario
    Given step one
    When step two
    Then step three

  Scenario: Run Defined scenario
    Given step one defined
    When step two defined
    Then step three defined

Sample stepdefinition

@Given("^step one$")
    public void stepOne() {
        // Write code here that turns the phrase above into concrete actions
        throw new PendingException();
    }

The result will show up as below. The 'steps' section will show only the first step as pending and the remaining as skipped. Though the 'scenario' section gives the pending scenario status as a whole.

2 Scenarios (1 pending, 1 passed)
6 Steps (2 skipped, 1 pending, 3 passed)
Grasshopper
  • 8,908
  • 2
  • 17
  • 32