Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dylanlacey/contrived
https://github.com/dylanlacey/contrived
Last synced: about 6 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/dylanlacey/contrived
- Owner: DylanLacey
- Created: 2013-06-27T06:58:48.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-06-28T03:11:02.000Z (over 11 years ago)
- Last Synced: 2023-03-12T06:43:47.516Z (over 1 year ago)
- Language: Ruby
- Size: 148 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
contrived
=========An Example showing how Sauce Labs can enhance your testing.
NOTE: This example is extremely contrived.
Pre-requisites
--------------------First, you'll need a Sauce Labs username and password, which you can get for free at (https://saucelabs.com/signup). Don't forget to add a promo code if you have one!
Next, set the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables to your username and access key, respectively. Your access key can be found on the lower left hand side of your Sauce Labs jobs page.
Have or install Ruby (I use [RVM](https://rvm.io/)). OS X Comes with an OLD version of Ruby... I recommend updating to 1.9
Have or install [git](http://git-scm.com/).
Install bundler with `gem install bundler`
Lastly, clone the example repository `git clone https://github.com/DylanLacey/contrived.git` and cd into its directory.
Examples
--------### No Sauce
The first example shows a test, running on your local copy of firefox. It opens Firefox and performs each test sequentially.
1. Check the example out: `git checkout no-sauce`
2. Install all required gems: `bundle update`
3. Run the example: `bundle exec rspec`### Sequential Sauce
The second example shows both tests being run sequentially on Sauce Labs' infrastructure. The examples are run using IE 10 on Windows 8.
1. Check the example out: `git checkout sequential-sauce`
2. Install all required gems: `bundle update`
3. Run the example: `bundle exec rspec`
4. Log into your Sauce Labs account once the test completes, and check it outIf you compare this code with the previous examples, you'll see just how easy it is to run tests on Sauce Labs.
The major change is that we registered a new driver for Capybara (the tool allowing us to write simple directions for driving browsers), and that driver uses a remote Selenium server. You can see it in `spec/sauce_driver.rb` line 7 - 9. It's a simple matter of telling the WebDriver object to use a remote browser, pointing it at Sauce Labs' service, and requesting IE.
This example also illustrates one of the caveats for Selenium. It doesn't have a concept of "passing" or "failing" tests, all it's concerned with is whether or not certain actions and content are available. When you log into our serivce, you'll see that the job is un-named, and the result is "Finished". You could fix this using our [REST API](http://saucelabs.com/docs/rest).
### Parallel Sauce
The third example shows the power of abstracting away your infrastructure and using Sauce Labs to run your integration tests.
Four browsers are used:
* IE 10 on Windows 8
* Safari 5 on iPad
* Opera 12 on Linux
* Safari 6 on OSX 10.8We're going to see 8 tests in total, one for each test on every browser.
We're also using the sauce gem to give us automatic parallelization, result reporting and test naming.
1. Check the example out: `git checkout parallel-sauce`
2. Install all required gems: `bundle update`
3. Run the example: `bundle exec sauce:spec`
4. Log into your Sauce Labs account and watch your tests runYou'll notice you can load tests while they're running, and watch the test taking place. It's even possible to interrupt tests and take them over, which helps immensely with debugging.