Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Overview

In this tutorial, we will perform some web/UI-based tests using Gwen interpreter along with gwen-web engine.

...

From the many interesting features of Gwen is we can highlight the auto-update capability and also the ability of automatically taking screenshots, which will be available for analysis after tests are run.

...

Besides that, you need 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?


Info
titleLearn more

Please see Testing in BDD with Gherkin based frameworks (e.g. Cucumber) for an overview of the possible workflows.

Using Jira and Xray as master

...

Info
titlePlease note

This tutorial explores using Xray for storing and managing the Sceneathe declarative scenarios and not the ones contained within the meta-features.

However, it should also be possible to manage them as Test issues with a "StepDef" label; it would require further evaluation though.


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 being exported, the created .feature 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
titlefeatures/google.feature
@REQ_CALC-4805
Feature: Google search (gwen-web-demo)


	@TEST_CALC-4823
	Scenario: Perform a google search
		Given I have Google in my browser
		When I do a search for "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 quicklyThe steps correspond to reusable blocks, defined as @StepDef scenarios within meta-feature files like the following one.


Code Block
languagejava
titlefeatures/google/Google.meta
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"


In this example, we're assuming that this meta-feature is not imported to Xray nor managed there; thus, it will probably live in the VCS.

Besides the previous example, there are also There are additional tests for interacting with a demo page, with corresponding meta specification.


Gwen loads both standard and meta-features and finds the right code to execute.

After running the tests and generating the Cucumber JSON  report (e.g., datamerged-test-results.json), it can be imported to Xray via the REST API or the Import Execution Results action within the Test Execution.

The cucumber-json-merge utility may be handy to merge the results of each feature.


No Format
./gwen -b -m meta -f json -r target/reports features
cucumber-json-merge -d target/reports/json/
curl -H "Content-Type: application/json" -X POST -u admin:admin --data @"merged-test-results.json" http://jiraserver.example.com/rest/raven/1.0/import/execution/cucumber

Image Removed


The execution screen details will provide information on the test run result that includes step-level information including duration.


Image RemovedImage Added


As shown above, besides a detailed error message,  screenshots are also automatically available on failed steps.

...

titleLearn more

...

If we wanted to correct the previous error, we could go to the Test and update its definition and run the tests again.

Using Git or other VCS as master

...

In any case, you'll need to synchronize your .feature files to Jira so that you can have visibility of them and report results against them...

Thus, you need to import your .feature files to Xray/Jira; you can invoke the REST API directly or use one of the available plugins/tutorials for CI tools.


Given I have Google in my browser When I do a search for "Gwen automation" Then the first result should open a Gwen page
Code Block
titleScenario: Perform a google search
zip -r features.zip features/ -i \*.feature
curl -H "Content-Type: multipart/form-data" -u admin:admin -F "file=@features.zip" "http://jiraserver.example.com/rest/raven/1.0/import/feature?projectKey=CALC"



Info
titlePlease note

Each Scenario of each .feature will be created as a Test issue that contains unique identifiers, so that if you import once again then Xray can update the existent Test and don't create any duplicated tests.


Afterward, you can export those features out of Jira based on some criteria, so they are properly tagged, run them and import back the results to correct entities in Xray.

References

...