Project

cloud_test

0.0
Repository is archived
No release in over 3 years
Low commit activity in last 3 years
Enables cross-browser-testing with by the integration of the following providers Browserstack, Crossbrowsertesting, Saucelabs and lambdatest. Based on cucumber and capybara
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

cloud_test

cloud_test enables local Cloud-Testing for a number of providers:

  • Browserstack
  • CrossBrowserTesting
  • saucelabs
  • lambdatest

The intention of this gem is to quickly enable Cloud-Testing with minimal setup required. It assumes your are using capybara and selenium.

Installation

Add this line to your application's Gemfile:

gem 'cloud_test'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cloud_test

Configuration

You can configure cloud_test in the

config/cloud_test.yml file 

The minimal config includes a 'key' and a 'user' value (which may be or not be the login credentials for the chosen provider), as well as 'provider' value. Additional key/value pairs are possible, for example to configure the browser.

You can generate the following example config file to the config folder with:

[bundle exec] cloud_test generate [-p PROVIDER]

Example cloud_test.config.yml:

#config/cloud_test.yml 
provider: "browserstack"
user: "username" # these may not be the login credentials
key: "password"
cloud_test_debug: false
common_caps:
  "acceptSslCerts": true # allow self signed certificates
browserstack: #optional block
  "browserstack.local": true
  "browserstack.debug": true # Visual log
browsers:
  IE:
    "browser": "IE"
    "browser_version": "11.0"
    "os": "Windows"
    "os_version": "7"
  CHROME:
    "browser": "chrome"
    "browser_version": "75.0"
    "os": "Windows"
cucumber_tag: "@cloudtest"

You can choose a specific browser configuration by setting the CLOUD_TEST env variable to your preconfigured browser settings by:

export CLOUD_TEST=<BROWSER_CONFIG>
# or
CLOUD_TEST=<BROWSER_CONFIG> cucumber

The provider Hash can include specific configuration only for that provider, common_caps and browser_caps are provider independent.

NOTE: Theses capabilities may still be slightly different for each provider. If you set the cloud_test_debug key to true cloud_test will display some additional details.

And these are the defaults and possible env variable settings:

[bundle exec] cloud_test list-default-caps PROVIDER
# will show something like this:

ENV['CLOUDTEST_PROJECT'] || # folder name
ENV['CLOUDTEST_BUILD'] ||  `git rev-parse HEAD` # HEAD commit hash
ENV['CLOUDTEST_NAME'] || `git log -1 --pretty=%B` # HEAD commit message
ENV['CLOUDTEST_OS'] || '10'
ENV['CLOUDTEST_PLATFORM'] || 'WINDOWS'
ENV['CLOUDTEST_BROWSER'] || 'CHROME'

Additionally you can do a dry run and show the "real" capabilities:

[bundle exec] cloud_test list-caps PROVIDER

Usage

You do need a config file, read the configuration section above first. You need to run the specific tunnel app for each provider in order to setup local testing. Links:

Download the one for your provider and operating system. Extract the executable and run it. The command should be similar to:

./<path_to>/<tunnel> -u <username> -k <password|apikey>

To enable Cloud_Testing you need to set the ENV['CLOUD_TEST'] variable to any value.

export CLOUD_TEST=IE
# or
CLOUD_TEST=IE cucumber 

The value can be a browser_caps configuration key (e.g. IE, chrome, my_ie_browser_config), and must be defined in the config file.

Additionally you need to require 'cloud_test' and set the capybara driver in the features/support/cloud_test.rb file as follows, it can be generated automatically if you run:

[bundle exec] cloud_test generate [-p PROVIDER]


require 'cloud_test'

if CloudTest.enabled?
  Before do
    Capybara.current_driver = :cloud_test
  end
  After do |scenario|
      if scenario.failed?
          CloudTest.upload_status_to_provider true, page.driver.browser.session_id, scenario.exception
      end
    end
end

NOTE: cloud_test registers a Capybara driver named ':cloud_test'.

The After hook updates the status in the dashboard of your provider. Currently this is implemented for browserstack and crossbrowsertesting.

If you want to test your whether your login credentials work, you can use the following command:

[bundle exec] cloud_test test-connection

To automate things even further you can define a cucumber tag in the config file (default: '@cloudtest'), tag all scenarios you wish to run and run the following command:

[bundle exec] cloud_test cucumber [-q]

This command will run all tagged scenarios sequantially with all browser configurations defined in the 'browsers' list in your config file. It runs the following command for each browser:

CLOUD_TEST=<browser_config_name> bundle exec cucumber -t <cucumber_tag>

You can also use the following command to execute your own test-command:

[bundle exec] cloud_test each [-q] <run> <your> <test-suite> 

You can get a list of all available commands with a description if you run:

[bundle exec] cloud_test

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/makandra/cloud_test. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Cloudtest project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.