Skip to content

Commit 47adc7b

Browse files
authored
Merge pull request #1 from browserstack/app_automate_tests
Add App Automate tests
2 parents 313adf5 + d2a2ac3 commit 47adc7b

28 files changed

+625
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
local.log

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
# cucumber-ruby-appium-app-browserstack
1+
cucumber-ruby-app-browserstack
2+
=====================
3+
![BrowserStack Logo](https://d98b8t1nnulk5.cloudfront.net/production/images/layout/logo-header.png?1469004780)
4+
5+
Code samples to get started with Appium tests for your Native App using the Cucumber framework.
6+
7+
## Resources
8+
* [Get Started guide](https://www.browserstack.com/app-automate/appium-cucumber)
9+
* [Android sample code repo](https://github.com/browserstack/cucumber-ruby-appium-app-browserstack/tree/master/android)
10+
* [IOS sample code repo](https://github.com/browserstack/cucumber-ruby-appium-app-browserstack/tree/master/ios)

android/Gemfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
source 'http://rubygems.org'
2+
3+
gem 'cucumber'
4+
gem 'selenium-cucumber'
5+
gem 'selenium-webdriver'
6+
gem 'rspec'
7+
gem 'rake'
8+
gem 'browserstack-local'
9+
gem 'parallel_tests'
10+
gem 'appium_lib'

android/Gemfile.lock

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
GEM
2+
remote: http://rubygems.org/
3+
specs:
4+
appium_lib (9.7.1)
5+
awesome_print (~> 1.8)
6+
json (>= 1.8)
7+
nokogiri (~> 1.6, >= 1.6.6)
8+
selenium-webdriver (~> 3.4, >= 3.4.1)
9+
tomlrb (~> 1.1)
10+
awesome_print (1.8.0)
11+
backports (3.8.0)
12+
browserstack-local (1.3.0)
13+
builder (3.2.3)
14+
childprocess (0.8.0)
15+
ffi (~> 1.0, >= 1.0.11)
16+
chunky_png (1.3.8)
17+
cucumber (3.0.1)
18+
builder (>= 2.1.2)
19+
cucumber-core (~> 3.0.0)
20+
cucumber-expressions (~> 4.0.3)
21+
cucumber-wire (~> 0.0.1)
22+
diff-lcs (~> 1.3)
23+
gherkin (~> 4.0)
24+
multi_json (>= 1.7.5, < 2.0)
25+
multi_test (>= 0.1.2)
26+
cucumber-core (3.0.0)
27+
backports (>= 3.8.0)
28+
cucumber-tag_expressions (>= 1.0.1)
29+
gherkin (>= 4.1.3)
30+
cucumber-expressions (4.0.4)
31+
cucumber-tag_expressions (1.0.1)
32+
cucumber-wire (0.0.1)
33+
diff-lcs (1.3)
34+
ffi (1.9.18)
35+
gherkin (4.1.3)
36+
json (2.1.0)
37+
mini_portile2 (2.3.0)
38+
multi_json (1.12.2)
39+
multi_test (0.1.2)
40+
nokogiri (1.8.1)
41+
mini_portile2 (~> 2.3.0)
42+
parallel (1.12.0)
43+
parallel_tests (2.17.0)
44+
parallel
45+
rake (12.0.0)
46+
rspec (3.6.0)
47+
rspec-core (~> 3.6.0)
48+
rspec-expectations (~> 3.6.0)
49+
rspec-mocks (~> 3.6.0)
50+
rspec-core (3.6.0)
51+
rspec-support (~> 3.6.0)
52+
rspec-expectations (3.6.0)
53+
diff-lcs (>= 1.2.0, < 2.0)
54+
rspec-support (~> 3.6.0)
55+
rspec-mocks (3.6.0)
56+
diff-lcs (>= 1.2.0, < 2.0)
57+
rspec-support (~> 3.6.0)
58+
rspec-support (3.6.0)
59+
rubyzip (1.2.1)
60+
selenium-cucumber (3.1.5)
61+
appium_lib (>= 8.0.2)
62+
chunky_png (>= 1.3.5)
63+
cucumber (>= 2.3.0)
64+
rspec (>= 3.4.0)
65+
selenium-webdriver (>= 2.53.0)
66+
selenium-webdriver (3.6.0)
67+
childprocess (~> 0.5)
68+
rubyzip (~> 1.0)
69+
tomlrb (1.2.5)
70+
71+
PLATFORMS
72+
ruby
73+
x86_64-darwin-16
74+
75+
DEPENDENCIES
76+
appium_lib
77+
browserstack-local
78+
cucumber
79+
parallel_tests
80+
rake
81+
rspec
82+
selenium-cucumber
83+
selenium-webdriver
84+
85+
BUNDLED WITH
86+
1.15.3

android/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Setup
2+
* Clone the repo
3+
* Install dependencies `bundle install`
4+
* Update `.config.yml` files inside the `config` directory with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings).
5+
6+
## Running your tests
7+
* Upload your Native App (.apk file) to BrowserStack servers using upload API:
8+
9+
```
10+
curl -u "username:accesskey" -X POST "https://api.browserstack.com/app-automate/upload" -F "file=@/path/to/app/file/Application-debug.apk"
11+
```
12+
13+
* If you do not have an .apk file and looking to simply try App Automate, [you can download our sample app and upload](https://www.browserstack.com/app-automate/sample-apps/android/WikipediaSample.apk)
14+
to the BrowserStack servers using the above API.
15+
* For running local tests, you can use our [local sample app](https://www.browserstack.com/app-automate/sample-apps/android/LocalSample.apk).
16+
* Update the desired capability "app" with the App URL returned from the above API call
17+
* To run a single test, run `bundle exec rake single`
18+
* To run parallel tests, run `bundle exec rake parallel`
19+
* To run local tests, run `bundle exec rake local`
20+
21+
## Notes
22+
* You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/app-automate)
23+
* Refer [Get Started](https://www.browserstack.com/app-automate/appium-cucumber) document to configure the capabilities
24+
* You can export the environment variables for the Username and Access Key of your BrowserStack account.
25+
26+
```
27+
export BROWSERSTACK_USERNAME=<browserstack-username> &&
28+
export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
29+
```
30+
31+
## Addtional Resources
32+
* [Cucumber](https://cucumber.io/)
33+
* [Getting Started with App Automate](https://www.browserstack.com/app-automate/appium-cucumber)

android/Rakefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
require 'rake'
2+
require 'parallel'
3+
require 'cucumber/rake/task'
4+
5+
Cucumber::Rake::Task.new(:single) do |task|
6+
ENV['CONFIG_NAME'] ||= "single"
7+
task.cucumber_opts = ['--format=pretty', 'features/single.feature']
8+
end
9+
10+
task :default => :single
11+
12+
Cucumber::Rake::Task.new(:local) do |task|
13+
task.cucumber_opts = ['--format=pretty', 'features/local.feature', 'CONFIG_NAME=local']
14+
end
15+
16+
task :parallel do |t, args|
17+
@num_parallel = 4
18+
19+
Parallel.map([*1..@num_parallel], :in_processes => @num_parallel) do |task_id|
20+
ENV["TASK_ID"] = (task_id - 1).to_s
21+
ENV['name'] = "parallel_test"
22+
ENV['CONFIG_NAME'] = "parallel"
23+
24+
Rake::Task["single"].invoke
25+
Rake::Task["single"].reenable
26+
end
27+
end
28+
29+
30+
task :test do |t, args|
31+
Rake::Task["single"].invoke
32+
Rake::Task["single"].reenable
33+
Rake::Task["local"].invoke
34+
Rake::Task["parallel"].invoke
35+
end

android/config/local.config.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
server: "hub.browserstack.com"
2+
user: "BROWSERSTACK_USERNAME"
3+
key: "BROWSERSTACK_ACCESS_KEY"
4+
5+
common_caps:
6+
"build": "cucumber-browserstack"
7+
"browserstack.debug": true
8+
9+
browser_caps:
10+
-
11+
"device": "Google Pixel"
12+
"realMobile": true
13+
"app": "bs://<hashed app-id>"
14+
"browserstack.local": true
15+
"name": "local_test"

android/config/parallel.config.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
server: "hub.browserstack.com"
2+
user: "BROWSERSTACK_USERNAME"
3+
key: "BROWSERSTACK_ACCESS_KEY"
4+
5+
common_caps:
6+
"build": "cucumber-browserstack"
7+
"browserstack.debug": true
8+
9+
browser_caps:
10+
-
11+
"device": "Google Pixel"
12+
"realMobile": true
13+
"app": "bs://<hashed app-id>"
14+
"name": "parallel_test"
15+
-
16+
"device": "Google Nexus 5"
17+
"realMobile": true
18+
"app": "bs://<hashed app-id>"
19+
"name": "parallel_test"
20+
-
21+
"device": "Samsung Galaxy S7"
22+
"realMobile": true
23+
"app": "bs://<hashed app-id>"
24+
"name": "parallel_test"

android/config/single.config.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
server: "hub.browserstack.com"
2+
user: "BROWSERSTACK_USERNAME"
3+
key: "BROWSERSTACK_ACCESS_KEY"
4+
5+
common_caps:
6+
"build": "cucumber-browserstack"
7+
"browserstack.debug": true
8+
9+
browser_caps:
10+
-
11+
"device": "Google Pixel"
12+
"realMobile": true
13+
"app": "bs://<hashed app-id>"
14+
"name": "single_test"

android/features/local.feature

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Feature: BrowserStack Local Testing
2+
3+
Background:
4+
Given I start test on the Local Sample App
5+
6+
Scenario: Can check tunnel working
7+
Then I should see "Up and running"

0 commit comments

Comments
 (0)