Versions Compared

Key

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

...

The test (specification) is initially created in Jira as a Cucumber Test and complemented with a Pre-Condition; later on it is exported using the UI or the REST API and run in BrowserStack mobile devices.


Info
titlePlease note

Within this tutorial, only one Test Execution will be used; it will contain one Test Run with all the results for the different used devices. Thus, the overall test run status will be affected by the results made for all the devices.

Instead of this approach, a different one could be creating a Test Execution per each device. The steps would need to be slightly different. namelly the submission process would need to use the standard or multipart Cucumber REST API endpoints, for each result file corresponding to each device. This approach would give the ability to take advantage of Test Environments (more info in Working with Test Environments).


Requirements

  • Install Ruby (or JRuby)
  • Install install all dependencies using "bundle install", on the "cucumberandroid" gemsub-folder

Description

This tutorial is based on BrowserStack's own tutorial for Appium/Cucumber/Ruby.

...

No Format
 git clone https://github.com/browserstack/cucumber-ruby-appium-app-browserstack
 cd android


We'll use the Android "android" example folder as basis and the "parallel" task that runs the tests in parallel.

...

Code Block
titleconfig/parallel.config.yml
server: "hub-cloud.browserstack.com"
user: "sergiofreire1youruser"
key: "Q75qUuWwumyKvpXq6Kg4yourkey"

common_caps:
  "build": "cucumber-browserstack"
  "browserstack.debug": true

browser_caps:
  -
    "device": "Google Pixel"
    "app": "bs://6c31566b71e1ee4c5f7f5298c702c0de4c590000"
    "name": "parallel_test"
  -
    "device": "Google Nexus 6"
    "app": "bs://6c31566b71e1ee4c5f7f5298c702c0de4c590000"
    "name": "parallel_test"

...

In this tutorial we're using a wikipedia sample application from BrowserStack, that must be uploaded beforehand to BrowserStack. The hashed app id must be configured accordingly on the previous configuration file.


Instead of using the provided "single.feature" file, we'll use JIRA and Xray as master of information.

In other words, in JIRA we'll:

  1. create a story
  2. create a Test for it
  3. create a Pre-Condition and associate it to the previous Test

Although it's not needed, we will also create a blank Test Execution with the Test and we'll use it as basis in order to run and report our test results.

Image Added

Image Added   Image Added


After creating a Cucumber Test, of Cucumber Type "Scenario Outline", in Jira, you can export the specification of the test to a Cucumber .feature file via the REST API or the the Export to Cucumber UI  UI action from within the Test Execution issue.

...

Code Block
titlefeatures/single.feature
@CALC-2130
@REQ_CALC-2131
Feature: As a user, I can search in Wikipedia App

	Background:
		#@CALC-2133
		Given I try to search using Wikipedia App


	@TEST_CALC-2132
	Scenario: Search for a term
		  When I type in "BrowserStack"
		  Then I should see results

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.


Tests can be run by execution rake's "parallel" task.

No Format
 bundle exec rake parallel


The previous task will generate a Cucumber JSON report per each target device. 

No Format
zip browserstack.zip device_*.json


These files can be bundled in ZIP file and submitted to Xray using the "bundle" REST API endpoint (either by invoking the REST API directly or by using one of the free add-ons for Jenkins/Bamboo).

Code Block
titleExample for submission of results using "curl"
curl -H "Content-Type: multipart/form-data" -u user:password -F "file=@browserstack.zip" https://sandbox.xpand-addons.com/rest/raven/1.0/import/execution/bundle
No Format
 bundle exec rake parallel


The execution screen details will not only provide information on the test run result, but also of each of the examples provided in the Scenario Outline.

Info

The Cucumber Scenarios Example/Result details (i.e., Hooks, Backgrounds and Steps) are only available for executions done in Xray v2.2.0 and above.

 Image Removed

...

for each step.

For each device, a different "context" will appear along with the respective step results.


Image Added

...


Info
titleLearn more

Please see Testing with Cucumber for an overview on how to use Cucumber Tests with Xray.


In BrowserStack you can see some info about it.

Image Added

References

...