Page History
...
- gwen
- gwen-web
- cucumber-json-merge
npm install -g cucumber-json-merge
Description
We will use the sample code from the Github repository "cucumber-java-skeleton", with slight changes in order to make the dummy Test pass gwen-web repository, using some instructions available online.
The first thing to decide is which workflow we'll use: do we want to use Xray/Jira as the master for writing the declarative specification or do we want to manage those in Git?
The tutorial assumes using Xray as master.
The first step is to create a Cucumber Test, of Cucumber Type "Scenario", in Jira. The specification would be exactly the same as the one provided in the original repository.
After creating the Test in Jira and associating it with requirements, etc., you can export the specification of the test to a Cucumber .feature file via the REST API or the Export to Cucumber UI action from within the Test Execution issue.
The created file will be similar to the original, but will contain the references to the Test issue key and the covered requirement issue key.
Code Block | ||
---|---|---|
| ||
@ABC-100 Feature: Belly @ABC-122 Scenario: a few cukes @REQ_CALC-4805 Feature: Google search (gwen-web-demo) @TEST_CALC-4823 @1_CALC-4805.feature @features/1_CALC-4805.feature @features/google/Google.feature @id:1 Scenario: Perform a google search Given I have 42 cukesGoogle in my bellybrowser When I do a Whensearch Ifor wait 1 hour Then my belly should growl"Gwen automation" Then the first result should open a Gwen page |
You can change the implementation of the steps in order to make them pass quickly.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| package skeleton;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class Stepdefs {
@Given("^I have (\\d+) cukes in my belly$")
public void I_have_cukes_in_my_belly(int cukes) throws Throwable {
Belly belly = new Belly();
belly.eat(cukes);
}
@When("^I wait (\\d+) hour$")
public void I_wait_hours(int hours) throws Throwable {
Thread.sleep(hours*0);
}
@Then("^my belly should growl$")
public boolean my_belly_should_growl() throws Throwable {
return true;
}
}
| |||||
Feature: Google search meta
@StepDef
Scenario: I have Google in my browser
Given I start a new browser
When I navigate to "http://www.google.com"
Then the page title should be "Google"
@StepDef
Scenario: I do a search for "<query>"
Given the search field can be located by name "q"
When I enter "$<query>" in the search field
Then the page title should contain "$<query>"
@StepDef
Scenario: the first result should open a Gwen page
Given the first match can be located by css selector ".r > a"
When I click the first match
Then the current URL should contain "gwen-interpreter" |
There are additional tests for interacting with a demo page, with corresponding meta specification.
After running the tests and generating the Cucumber JSON report (e.g., data.json), it can be imported to Xray via the REST API or the Import Execution Results action within the Test Execution.
...
Info | ||
---|---|---|
| ||
Please see Testing in BDD with Gherkin based frameworks (e.g. Cucumber) for an overview of the possible workflows. |
Using
...
Git as master
...
Code Block | ||
---|---|---|
| ||
Given I have Google in my browser
When I do a search for "Gwen automation"
Then the first result should open a Gwen page |
References
- https://github.com/gwen-interpreter/gwen
- https://github.com/gwen-interpreter/gwen-web
- https://gweninterpreter.wordpress.com/
- Testing in BDD with Gherkin based frameworks (e.g. Cucumber)
- https://github.com/bitcoder/cucumber-json-merge
- Automated Tests (Import/Export)
- Exporting Cucumber Tests - REST
...