cs-bdd 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +21 -0
- data/Rakefile +2 -0
- data/bin/cs-bdd +93 -0
- data/bin/cs-bdd-generate.rb +11 -0
- data/bin/cs-bdd-helpers.rb +73 -0
- data/cs-bdd.gemspec +23 -0
- data/lib/cs/bdd.rb +7 -0
- data/lib/cs/bdd/version.rb +5 -0
- data/lib/examples/example.feature +7 -0
- data/lib/examples/example_screen.rb +15 -0
- data/lib/examples/example_steps.rb +5 -0
- data/lib/skeleton/.gitignore +3 -0
- data/lib/skeleton/README.md +167 -0
- data/lib/skeleton/config/cucumber.yml +7 -0
- data/lib/skeleton/config/scripts/android/run_tests_all_devices.sh +24 -0
- data/lib/skeleton/config/scripts/ios/build_app.sh +38 -0
- data/lib/skeleton/config/scripts/ios/devices +4 -0
- data/lib/skeleton/config/scripts/ios/run_tests_all_devices.sh +44 -0
- data/lib/skeleton/features/android/android_screen_base.rb +98 -0
- data/lib/skeleton/features/android/features/.gitkeep +0 -0
- data/lib/skeleton/features/android/features/android.feature +9 -0
- data/lib/skeleton/features/android/screens/example_screen.rb +15 -0
- data/lib/skeleton/features/android/steps_definition/.gitkeep +0 -0
- data/lib/skeleton/features/android/support/app_installation_hooks.rb +43 -0
- data/lib/skeleton/features/android/support/app_life_cycle_hooks.rb +13 -0
- data/lib/skeleton/features/android/support/hooks.rb +0 -0
- data/lib/skeleton/features/example.feature +9 -0
- data/lib/skeleton/features/ios/features/.gitkeep +0 -0
- data/lib/skeleton/features/ios/features/ios.feature +9 -0
- data/lib/skeleton/features/ios/ios_screen_base.rb +134 -0
- data/lib/skeleton/features/ios/screens/example_screen.rb +0 -0
- data/lib/skeleton/features/ios/steps_definition/.gitkeep +0 -0
- data/lib/skeleton/features/ios/support/01_launch.rb +84 -0
- data/lib/skeleton/features/ios/support/02_pre_stop_hooks.rb +0 -0
- data/lib/skeleton/features/step_definitions/base_steps.rb +39 -0
- data/lib/skeleton/features/support/env.rb +5 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8fea4af1f1c087b62438cbecf42def2f539e2fe1
|
4
|
+
data.tar.gz: affd1d59330b9ed5811fd65a099ec723de85ad24
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bef6f96f0d15ce28ccf31738bf1641f1da1d7449f7e317c5b700f473d3bf42ec7beff9872360eb879a33cc2dc357b34348fe8867e315325a0bbdeb0f101a39ae
|
7
|
+
data.tar.gz: 90370746239e9a6f3f0e3f5b9c5565aec684e0fffdcc9936c45d2e8d0fbff009c1b5f78c54db06b1b348e3ff923e73246a613472e198e85964aba57e46b57bc9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in cs-bdd.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
# calabash gems
|
7
|
+
gem 'calabash-common'
|
8
|
+
# Only for Linux
|
9
|
+
if RUBY_PLATFORM.include? 'linux'
|
10
|
+
gem 'calabash-android'
|
11
|
+
else # Only for Mac. This gem will not be used in Windows
|
12
|
+
gem 'calabash-cucumber'
|
13
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 CSOscarTanner
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# CS::BDD
|
2
|
+
|
3
|
+
A simple gem to generate all the files needed to create a project that will support calabash for Android and iOS.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install it as:
|
8
|
+
|
9
|
+
$ gem install cs-bdd
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
TODO: Write usage instructions here
|
14
|
+
|
15
|
+
## Contributing
|
16
|
+
|
17
|
+
1. Fork it ( https://github.com/CSOscarTanner/cs-bdd/fork )
|
18
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
19
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
20
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
21
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/cs-bdd
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# File based on https://github.com/calabash/calabash-android/blob/e2da2817809edf38256a55093dc1d3835c9c6410/ruby-gem/bin/calabash-android
|
4
|
+
|
5
|
+
require 'fileutils'
|
6
|
+
require 'rbconfig'
|
7
|
+
require_relative '../lib/cs/bdd/version'
|
8
|
+
|
9
|
+
# for ruby 1.9.1 and earlier
|
10
|
+
unless defined? RbConfig.ruby
|
11
|
+
def RbConfig.ruby
|
12
|
+
File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
require File.join(File.dirname(__FILE__), "cs-bdd-generate")
|
17
|
+
require File.join(File.dirname(__FILE__), "cs-bdd-helpers")
|
18
|
+
|
19
|
+
@skeleton_dir = File.join( File.dirname(__FILE__), '..', 'lib', 'skeleton' )
|
20
|
+
@examples_dir = File.join( File.dirname(__FILE__), "..", "lib", "examples" )
|
21
|
+
@features_dir = File.join( FileUtils.pwd, "features" )
|
22
|
+
@steps_dir = File.join(@features_dir, "step_definitions" )
|
23
|
+
@android_dir = File.join(@features_dir, "android" )
|
24
|
+
@ios_dir = File.join(@features_dir, "ios" )
|
25
|
+
|
26
|
+
if ARGV.length == 0
|
27
|
+
print_usage
|
28
|
+
else
|
29
|
+
cmd = ARGV.shift
|
30
|
+
|
31
|
+
case cmd
|
32
|
+
when 'new', 'n'
|
33
|
+
if ARGV.empty?
|
34
|
+
puts "Please specify the project name"
|
35
|
+
exit 1
|
36
|
+
else
|
37
|
+
@project_dir = File.join(FileUtils.pwd, ARGV.first)
|
38
|
+
generate_skeleton
|
39
|
+
end
|
40
|
+
when 'generate', 'g'
|
41
|
+
|
42
|
+
# Looks if the user is in the root folder of the project
|
43
|
+
unless Dir.exists? File.join(FileUtils.pwd, "features", "android", "features")
|
44
|
+
puts "Please run this command on the root folder of the project"
|
45
|
+
exit 1
|
46
|
+
end
|
47
|
+
|
48
|
+
if ARGV.empty?
|
49
|
+
puts "Please inform the generator that will be used. Type cs-bdd to see the usage info."
|
50
|
+
exit 1
|
51
|
+
else
|
52
|
+
generator = ARGV.shift
|
53
|
+
|
54
|
+
if ARGV.empty?
|
55
|
+
puts "Please specify the name of the resource to be generated."
|
56
|
+
exit 1
|
57
|
+
end
|
58
|
+
|
59
|
+
name = ARGV.first
|
60
|
+
|
61
|
+
case generator
|
62
|
+
when 'feature'
|
63
|
+
create_feature_file name
|
64
|
+
create_steps_file name
|
65
|
+
create_screen_file name, 'IOS'
|
66
|
+
create_screen_file name, 'Android'
|
67
|
+
when 'aFeature'
|
68
|
+
create_feature_file name, 'Android'
|
69
|
+
create_steps_file name, 'Android'
|
70
|
+
create_screen_file name, 'Android'
|
71
|
+
when 'iFeature'
|
72
|
+
create_feature_file name, 'IOS'
|
73
|
+
create_steps_file name, 'IOS'
|
74
|
+
create_screen_file name, 'IOS'
|
75
|
+
when 'step'
|
76
|
+
create_steps_file name
|
77
|
+
when 'aStep'
|
78
|
+
create_steps_file name, 'Android'
|
79
|
+
when 'iStep'
|
80
|
+
create_steps_file name, 'IOS'
|
81
|
+
when 'aScreen'
|
82
|
+
create_screen_file name, 'Android'
|
83
|
+
when 'iScreen'
|
84
|
+
create_screen_file name, 'IOS'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
when 'version', 'v'
|
88
|
+
puts CS::BDD::VERSION
|
89
|
+
else
|
90
|
+
puts "Invalid command '#{cmd}'"
|
91
|
+
print_usage
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
def print_usage
|
2
|
+
puts <<EOF
|
3
|
+
Usage: cs-bdd <command-name> [parameters]
|
4
|
+
<command-name> can be one of
|
5
|
+
new or n <project_name>
|
6
|
+
generate a project folder structure
|
7
|
+
\033[0;32mEx.: cs-bdd n project_name\033[0m
|
8
|
+
generate or g <type> <name>
|
9
|
+
generate a Feature or Step Definition or Screen file
|
10
|
+
<type> can be one of
|
11
|
+
feature -> Generate all files that composes an OS independenty feature
|
12
|
+
aFeature -> Generate all files that composes an Android feature
|
13
|
+
iFeature -> Generate all files that composes an iOS feature
|
14
|
+
step -> Generate an OS independenty step
|
15
|
+
aStep -> Generate a step that will be loaded only in Android
|
16
|
+
iStep -> Generate a step that will be loaded only in iOS
|
17
|
+
aScreen -> Generate an Android screen
|
18
|
+
iScreen -> Generate an iOS screen
|
19
|
+
\033[0;32mEx.: cs-bdd g aFeature Feature_name\033[0m
|
20
|
+
version or v
|
21
|
+
prints the gem version
|
22
|
+
\033[0;32mEx.: cs-bdd v\033[0m
|
23
|
+
EOF
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_feature_file name, platform = nil
|
27
|
+
# Getting the contents of the example.feature file
|
28
|
+
content = File.read( File.join( @examples_dir, "example.feature" ) )
|
29
|
+
|
30
|
+
# Updating the contents with the name passed as an option
|
31
|
+
content = content.gsub( "|Name|", name.capitalize )
|
32
|
+
|
33
|
+
# If platform is not nil than the feature is OS dependent
|
34
|
+
file = nil
|
35
|
+
if platform.nil?
|
36
|
+
content = content.gsub( "|Platform|", "") # Don't show any indication of platform inside the feature file
|
37
|
+
file = File.join( @features_dir, "#{name.downcase}.feature" )
|
38
|
+
else
|
39
|
+
content = content.gsub( "|Platform|", "(#{platform} Only)") # Indicates the platform in the title of the feature
|
40
|
+
file = File.join( @features_dir, platform.downcase, "features", "#{name.downcase}.feature" )
|
41
|
+
end
|
42
|
+
|
43
|
+
# Creating the feature file with the updated content
|
44
|
+
File.open( file, 'w' ) { |file| file.puts content }
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_steps_file name, platform = nil
|
48
|
+
# Getting the contents of the example_steps.rb file
|
49
|
+
content = File.read( File.join( @examples_dir, "example_steps.rb" ) )
|
50
|
+
|
51
|
+
# If platform is not nil than the feature is OS dependent
|
52
|
+
file = nil
|
53
|
+
if platform.nil?
|
54
|
+
file = File.join( @steps_dir, "#{name.downcase}_steps.rb" )
|
55
|
+
else
|
56
|
+
file = File.join( @features_dir, platform.downcase, "steps_definition", "#{name.downcase}.feature" )
|
57
|
+
end
|
58
|
+
|
59
|
+
# Creating the steps file with the default content
|
60
|
+
File.open( file, 'w' ) { |file| file.puts content }
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_screen_file name, platform
|
64
|
+
# Getting the contents of the example_screen.rb file
|
65
|
+
content = File.read( File.join( @examples_dir, "example_screen.rb" ) )
|
66
|
+
|
67
|
+
# Updating the contents with the name passed as an option
|
68
|
+
content = content.gsub( "|Name|", name.capitalize )
|
69
|
+
content = content.gsub( "|Platform|", platform )
|
70
|
+
|
71
|
+
# Creating the feature file with the updated content
|
72
|
+
File.open( File.join( @features_dir, platform.downcase, "screens", "#{name.downcase}_screen.rb" ), 'w' ) { |file| file.puts content }
|
73
|
+
end
|
data/cs-bdd.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cs/bdd/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cs-bdd"
|
8
|
+
spec.version = CS::BDD::VERSION
|
9
|
+
spec.authors = ["Oscar Tanner"]
|
10
|
+
spec.email = ["oscar.tanner@concretesolutions.com.br"]
|
11
|
+
spec.summary = %q{Generates an android and iOS calabash project.}
|
12
|
+
spec.description = %q{A simple gem to generate all the folder and files needed to create an android and iOS calabash project.}
|
13
|
+
spec.homepage = "https://github.com/CSOscarTanner/cs-bdd"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = ["cs-bdd"]
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
data/lib/cs/bdd.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
class |Name|Screen < |Platform|ScreenBase
|
2
|
+
|
3
|
+
# The screen identificator
|
4
|
+
#trait(:trait) { "* marked:'#{layout_name}'" }
|
5
|
+
|
6
|
+
# Declare all the elements of this screen
|
7
|
+
#element(:layout_name) {'insert_layout_identificator'}
|
8
|
+
#element(:button) {'insert_button_identificator'}
|
9
|
+
|
10
|
+
# Declare all actions of this screen
|
11
|
+
# action(:touch_button) {
|
12
|
+
# touch("* marked:'#{button}'")
|
13
|
+
# }
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
#Getting Started
|
2
|
+
|
3
|
+
## Ruby
|
4
|
+
|
5
|
+
There is a lot of ways of installing ruby, one is using RVM (http://rvm.io/rvm/install):
|
6
|
+
|
7
|
+
Install RVM stable with ruby:
|
8
|
+
|
9
|
+
```
|
10
|
+
$ \curl -sSL https://get.rvm.io | bash -s stable --ruby
|
11
|
+
```
|
12
|
+
|
13
|
+
After this, include the following lines in you `~/.bashrc` file.
|
14
|
+
|
15
|
+
```
|
16
|
+
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
|
17
|
+
[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
|
18
|
+
```
|
19
|
+
|
20
|
+
# Android
|
21
|
+
|
22
|
+
## Installing the Gems
|
23
|
+
|
24
|
+
Install the following gems
|
25
|
+
|
26
|
+
```
|
27
|
+
gem install calabash-common
|
28
|
+
gem install calabash-android
|
29
|
+
```
|
30
|
+
|
31
|
+
**Warning!**
|
32
|
+
|
33
|
+
The command **`gem install calabash-android`** installs the beta version of the cucumber gem.
|
34
|
+
This gem brokes the execution of the calabash. After the installation of calabash-android, install the stable version of the cucumber gem (command: `gem install cucumber`) and remove the beta version (command: `gem uninstall cucumber`).
|
35
|
+
|
36
|
+
## Running the tests
|
37
|
+
To run the android tests, you need to:
|
38
|
+
|
39
|
+
1. Open the Android AVD
|
40
|
+
2. Open the terminal on the tests folder
|
41
|
+
3. Execute the command:
|
42
|
+
|
43
|
+
```
|
44
|
+
calabash-android run features/app-QA.apk -p android
|
45
|
+
```
|
46
|
+
|
47
|
+
|
48
|
+
> To run in a computer with more than one emulator or device, use the command:
|
49
|
+
>
|
50
|
+
>```
|
51
|
+
> ADB_DEVICE_ARG=emulator-5554 calabash-android run features/app-QA.apk -p android
|
52
|
+
>```
|
53
|
+
>
|
54
|
+
>Given that 'emulator-5554' is one of the returns of the command `$ adb devices` on the terminal
|
55
|
+
|
56
|
+
|
57
|
+
> To run on all connected devices, run the script `run_tests_all_devices.sh`, located on the `config/scripts/android` folder of the project
|
58
|
+
|
59
|
+
> **!! IMPORTANT !!**
|
60
|
+
|
61
|
+
> Remember to export the WORKSPACE variable with the path of the cloned test repository
|
62
|
+
|
63
|
+
> Remember to pass the APK path as the parameter of the script
|
64
|
+
>
|
65
|
+
> ```
|
66
|
+
> ./config/scripts/android/run_tests_all_devices.sh PATH_OF_APK_FILE
|
67
|
+
>```
|
68
|
+
|
69
|
+
|
70
|
+
## Calabash Terminal
|
71
|
+
|
72
|
+
The calabash terminal allows you to run the calabash commands without being on a test context
|
73
|
+
To open the calabash terminal, you need to:
|
74
|
+
|
75
|
+
1. Open the Android AVD
|
76
|
+
2. Open the terminal on the tests folder
|
77
|
+
3. Execute the command:
|
78
|
+
|
79
|
+
```
|
80
|
+
calabash-android console features/app-QA.apk -p android
|
81
|
+
```
|
82
|
+
|
83
|
+
4. Run the commands
|
84
|
+
|
85
|
+
```
|
86
|
+
reinstall_apps
|
87
|
+
start_test_server_in_background
|
88
|
+
```
|
89
|
+
|
90
|
+
5. Run the commands you want to.
|
91
|
+
|
92
|
+
# iOS
|
93
|
+
|
94
|
+
## Installing the Gems
|
95
|
+
|
96
|
+
Install the following gems
|
97
|
+
|
98
|
+
```
|
99
|
+
gem install calabash-common
|
100
|
+
gem install calabash-cucumber
|
101
|
+
```
|
102
|
+
|
103
|
+
## Configuring the iOS project
|
104
|
+
|
105
|
+
1. Run the command `pod install`
|
106
|
+
2. Run the command `calabash-ios setup` and follow the instructions
|
107
|
+
3. Make sure that the signing is a wildcard
|
108
|
+
|
109
|
+
|
110
|
+
## Running the tests
|
111
|
+
To run the iOS tests in a device, you need to:
|
112
|
+
|
113
|
+
1. Open the terminal on the tests folder
|
114
|
+
2. Compile the project to create the .app file with the command
|
115
|
+
|
116
|
+
```
|
117
|
+
./config/scripts/ios/build_app.sh xcworkspace_path TargetName-cal iphoneos8.1 ConfigurationName
|
118
|
+
```
|
119
|
+
|
120
|
+
PS.1: TargetName-cal is the name of the target created with the command `calabash-ios setup`
|
121
|
+
PS.2: iphoneos8.1 is the sdk for devices, for emulatores use iphonesimulator8.1
|
122
|
+
PS.3: Configuration name can be Dev, Debug, Release, Prod or any other configuration build
|
123
|
+
PS.4: The path to the .app file is the last output line of the above command
|
124
|
+
|
125
|
+
3. To execute one feature, run the command
|
126
|
+
|
127
|
+
```
|
128
|
+
APP_BUNDLE_PATH=AppFilePath DEVICE_TARGET=DeviceUUID DEVICE_ENDPOINT=CalabashServerEndpointDevice cucumber -p ios
|
129
|
+
```
|
130
|
+
|
131
|
+
4. To execute all the features in the configured devices run the script
|
132
|
+
|
133
|
+
```
|
134
|
+
./config/scripts/ios/run_tests_all_devices.sh AppFilePath
|
135
|
+
```
|
136
|
+
|
137
|
+
PS.: Remember to configure all the connected devices on the file `./config/scripts/ios/devices`.
|
138
|
+
In this file you need to inform the device UUID, the device IP with the calabash server port and a name to identify this device on the reports. Remember to leave an empty line at the end of the file and to split the informations using pipes.
|
139
|
+
|
140
|
+
## Calabash Terminal (Device)
|
141
|
+
|
142
|
+
The calabash terminal allows you to run the calabash commands without being on a test context
|
143
|
+
To open the calabash terminal, you need to:
|
144
|
+
|
145
|
+
1. Connect the device
|
146
|
+
2. Open the terminal on the tests folder
|
147
|
+
3. Execute the command:
|
148
|
+
|
149
|
+
```
|
150
|
+
APP_BUNDLE_PATH=AppFilePath DEVICE_TARGET=DeviceUUID DEVICE_ENDPOINT=CalabashServerEndpointDevice calabash-ios console
|
151
|
+
```
|
152
|
+
|
153
|
+
4. Run the command
|
154
|
+
|
155
|
+
```
|
156
|
+
start_test_server_in_background
|
157
|
+
```
|
158
|
+
|
159
|
+
5. Run the commands you want to.
|
160
|
+
|
161
|
+
## Pitfalls
|
162
|
+
|
163
|
+
1. Always build the project with the device connected
|
164
|
+
2. Ensure that the device is enabled to Development and the UI Automations is enabled on the Developer menu (Settings)
|
165
|
+
3. If the device in pin locked, ensure that it is unlocked. If there is no pin, the calabash will automatically unlock the device
|
166
|
+
4. Ensure that the device WIFI is enabled and it is accessible from the computer that is starting the tests. The calabash server works sending commands to the device by the network.
|
167
|
+
5. Always run the target -cal on the Xcode one first time to see if the target is ok and running. The calabash-ios gem cannot print errors of execution, but Xcode can.
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# config/cucumber.yml
|
2
|
+
##YAML Template
|
3
|
+
---
|
4
|
+
android: PLATFORM=android -r features/support -r features/android -r features/step_definitions --exclude features/ios
|
5
|
+
|
6
|
+
|
7
|
+
ios: PLATFORM=ios -r features/support -r features/ios -r features/step_definitions --exclude features/android
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
# ----------------------------------------------------------------------------
|
3
|
+
# Uncomment the next line to enable debug
|
4
|
+
# set -x
|
5
|
+
#
|
6
|
+
# $1 -> parameter with the name of the apk
|
7
|
+
|
8
|
+
|
9
|
+
## CODE BEGIN #############################################################
|
10
|
+
echo Start: $(date)
|
11
|
+
for device in $(adb devices | grep "device$" | cut -f 1)
|
12
|
+
do
|
13
|
+
rm -r $WORKSPACE/reports/$device &> /dev/null
|
14
|
+
mkdir -p $WORKSPACE/reports/$device &> /dev/null
|
15
|
+
echo $device | grep -q emulator
|
16
|
+
# SET THE IGNORE TAGS TRUE IF THE TEST ARE RUNNING IN A DEVICE
|
17
|
+
[ $? -ne 0 ] && ignore='--tags ~@ignore_if_test_in_device'
|
18
|
+
cd $WORKSPACE
|
19
|
+
ADB_DEVICE_ARG=$device SCREENSHOT_PATH=$WORKSPACE/reports/$device/ calabash-android run $1 -p android --format 'Calabash::Formatters::Html' --out $WORKSPACE/reports/$device/reports.html $ignore &
|
20
|
+
done
|
21
|
+
wait
|
22
|
+
echo End: $(date)
|
23
|
+
echo 'Bye!'
|
24
|
+
## CODE END #############################################################
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
# ----------------------------------------------------------------------------
|
3
|
+
# Uncomment the next line to enable debug
|
4
|
+
# set -x
|
5
|
+
#
|
6
|
+
# $1 -> xcworkspace path
|
7
|
+
# $2 -> target (scheme) name created by the command calabash-ios setup
|
8
|
+
# $3 -> sdk. This will differ from simulator and device build
|
9
|
+
# When this script was created the available sdks were: 'iphoneos8.1' for
|
10
|
+
# devices and iphonesimulator8.1 for simulator
|
11
|
+
# $4 -> Configuration type. Ex.: 'Dev'
|
12
|
+
|
13
|
+
## CODE BEGIN #############################################################
|
14
|
+
|
15
|
+
# When running on CI
|
16
|
+
# It is a good pratice to run pod install when executing this script on the CI to avoid
|
17
|
+
# building problems
|
18
|
+
# pod install
|
19
|
+
|
20
|
+
[ $# -ne 4 ] && echo "Wrong number of parameters." && exit 1
|
21
|
+
|
22
|
+
echo "Building project for calabash"
|
23
|
+
|
24
|
+
xcodebuild -workspace "$1" -scheme "$2" -sdk "$3" -configuration "$4" clean build
|
25
|
+
|
26
|
+
BUILT_PRODUCTS_DIR=`xcodebuild -workspace "$1" -scheme "$2" -sdk "$3" -showBuildSettings -configuration "$4" |
|
27
|
+
grep -i "\bbuilt_products_dir" |
|
28
|
+
cut -d "=" -f2 `
|
29
|
+
|
30
|
+
export APP_BUNDLE_PATH=`echo "$BUILT_PRODUCTS_DIR/$2.app" |
|
31
|
+
sed 's/^\ *//g' |
|
32
|
+
sed 's/\ *$//g'`
|
33
|
+
|
34
|
+
echo $APP_BUNDLE_PATH
|
35
|
+
|
36
|
+
echo End: $(date)
|
37
|
+
echo 'Bye!'
|
38
|
+
## CODE END #############################################################
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
# ----------------------------------------------------------------------------
|
3
|
+
# Uncomment the next line to enable debug
|
4
|
+
# set -x
|
5
|
+
#
|
6
|
+
# $1 -> parameter with the path of the .app bundle
|
7
|
+
|
8
|
+
## CODE BEGIN #############################################################
|
9
|
+
|
10
|
+
echo Start: $(date)
|
11
|
+
|
12
|
+
# Exits if the app path was not informed
|
13
|
+
if [ -z $1 ]; then
|
14
|
+
echo "The first parameter must be the app path"
|
15
|
+
exit 1
|
16
|
+
fi
|
17
|
+
|
18
|
+
# Reads the devices file line by line
|
19
|
+
while read line
|
20
|
+
do
|
21
|
+
# Ignoring all comments
|
22
|
+
echo $line | grep -q "^#" && continue
|
23
|
+
|
24
|
+
# Reading the informations of the device in the devices file
|
25
|
+
# The variables can't contain any kind of spaces, so we erase then off
|
26
|
+
target="$(echo $line | cut -d'|' -f1 | tr -d ' ')"
|
27
|
+
endpoint="$(echo $line | cut -d'|' -f2 | tr -d ' ')"
|
28
|
+
name="$(echo $line | cut -d'|' -f3 | tr -d ' ')"
|
29
|
+
|
30
|
+
# Cleaning the previous reports folder and ensuring its existence
|
31
|
+
rm -rf "$WORKSPACE/reports/$name" &> /dev/null
|
32
|
+
mkdir -p "$WORKSPACE/reports/$name" &> /dev/null
|
33
|
+
|
34
|
+
# Navigating to the tests root folder
|
35
|
+
cd "$WORKSPACE"
|
36
|
+
|
37
|
+
# Executing calabash for the device
|
38
|
+
APP_BUNDLE_PATH="$1" DEVICE_TARGET="$target" DEVICE_ENDPOINT="$endpoint" SCREENSHOT_PATH="$WORKSPACE/reports/$name/" cucumber -p ios --format 'Calabash::Formatters::Html' --out "$WORKSPACE/reports/$name/reports.html"
|
39
|
+
|
40
|
+
done < config/scripts/ios/devices
|
41
|
+
|
42
|
+
echo End: $(date)
|
43
|
+
echo 'Bye!'
|
44
|
+
## CODE END #############################################################
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'calabash-android/abase'
|
2
|
+
|
3
|
+
class AndroidScreenBase < Calabash::ABase
|
4
|
+
|
5
|
+
def self.element element_name
|
6
|
+
define_method element_name.to_s
|
7
|
+
end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
alias :value :element
|
11
|
+
alias :action :element
|
12
|
+
alias :trait :element
|
13
|
+
end
|
14
|
+
|
15
|
+
element(:loading_screen) {"insert_loading_view_id"}
|
16
|
+
|
17
|
+
# The progress bar of the application is a custom view
|
18
|
+
def wait_for_progress
|
19
|
+
wait_for_element_does_not_exist(loading_screen)
|
20
|
+
end
|
21
|
+
|
22
|
+
def drag_to direction
|
23
|
+
|
24
|
+
positions = [0,0,0,0] # [ 'from_x', 'to_x', 'from_y', 'to_y' ]
|
25
|
+
|
26
|
+
case(direction)
|
27
|
+
when :down
|
28
|
+
positions = [30,30,60,30]
|
29
|
+
when :up
|
30
|
+
positions = [80,80,60,90]
|
31
|
+
when :left
|
32
|
+
positions = [90,20,80,80]
|
33
|
+
when :right
|
34
|
+
positions = [20,90,80,80]
|
35
|
+
end
|
36
|
+
|
37
|
+
# perform_action( 'action', 'from_x', 'to_x', 'from_y', 'to_y', 'number of steps (in this case, velocity of drag' )
|
38
|
+
perform_action('drag', positions[0], positions[1], positions[2], positions[3], 15)
|
39
|
+
|
40
|
+
sleep(1)
|
41
|
+
end
|
42
|
+
|
43
|
+
def drag_until_element_is_visible_with_special_query direction, element
|
44
|
+
drag_until_element_is_visible direction, element, "* {text CONTAINS[c] '#{self.get_translation(element)}'}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def drag_until_element_is_visible direction, element, query = nil, limit = 15
|
48
|
+
i = 0
|
49
|
+
|
50
|
+
element_text = get_translation(element)
|
51
|
+
|
52
|
+
element_query = ""
|
53
|
+
if query.nil?
|
54
|
+
element_query = "* marked:'#{element_text}'"
|
55
|
+
else
|
56
|
+
element_query = query
|
57
|
+
end
|
58
|
+
|
59
|
+
sleep(2)
|
60
|
+
while( !element_exists(element_query) and i < limit) do
|
61
|
+
drag_to direction
|
62
|
+
i = i + 1
|
63
|
+
end
|
64
|
+
|
65
|
+
raise ("Executed #{limit} moviments #{direction.to_s} and the element '#{element_text}' was not found on this view!") unless i < limit
|
66
|
+
end
|
67
|
+
|
68
|
+
def drag_for_specified_number_of_times direction, times
|
69
|
+
times.times do
|
70
|
+
drag_to direction
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def is_on_page? page_text
|
75
|
+
|
76
|
+
translated_page_text = get_translation(page_text)[0,50] # Using only the first 50 chars in the comparation
|
77
|
+
|
78
|
+
begin
|
79
|
+
wait_for(:timeout => 5) { has_text? translated_page_text }
|
80
|
+
rescue
|
81
|
+
raise "Unexpected Page. Expected was: '#{translated_page_text}'"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def enter text, element, query = nil
|
86
|
+
if query.nil?
|
87
|
+
query( "* marked:'#{element}'", {:setText => text} )
|
88
|
+
else
|
89
|
+
query( query, {:setText => text} )
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def touch_element_by_index id, index
|
94
|
+
wait_for(:timeout => 5) { element_exists("* id:'#{id}' index:#{index}") }
|
95
|
+
touch("* id:'#{id}' index:#{index}")
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
File without changes
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Feature: Example Android
|
2
|
+
# This feature will only be executed when the android profile is loaded
|
3
|
+
# You can rename this file and update its contents or delete it and create new features
|
4
|
+
|
5
|
+
Background:
|
6
|
+
# Insert the steps
|
7
|
+
|
8
|
+
Scenario: First Scenario
|
9
|
+
# Insert the steps
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ExampleScreen < AndroidScreenBase
|
2
|
+
|
3
|
+
# The screen identificator
|
4
|
+
#trait(:trait) { "* marked:'#{layout_name}'" }
|
5
|
+
|
6
|
+
# Declare all the elements of this screen
|
7
|
+
#element(:layout_name) {'insert_layout_identificator'}
|
8
|
+
#element(:button) {'insert_button_identificator'}
|
9
|
+
|
10
|
+
# Declare all actions of this screen
|
11
|
+
# action(:touch_button) {
|
12
|
+
# touch("* marked:'#{button}'")
|
13
|
+
# }
|
14
|
+
|
15
|
+
end
|
File without changes
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'calabash-android/management/app_installation'
|
2
|
+
|
3
|
+
AfterConfiguration do |config|
|
4
|
+
FeatureNameMemory.feature_name = nil
|
5
|
+
end
|
6
|
+
|
7
|
+
Before('@reinstall') do |scenario|
|
8
|
+
uninstall_apps
|
9
|
+
install_app(ENV["TEST_APP_PATH"])
|
10
|
+
install_app(ENV["APP_PATH"])
|
11
|
+
end
|
12
|
+
|
13
|
+
Before do |scenario|
|
14
|
+
@scenario_is_outline = (scenario.class == Cucumber::Ast::OutlineTable::ExampleRow)
|
15
|
+
if @scenario_is_outline
|
16
|
+
scenario = scenario.scenario_outline
|
17
|
+
end
|
18
|
+
|
19
|
+
feature_name = scenario.feature.title
|
20
|
+
if FeatureNameMemory.feature_name != feature_name \
|
21
|
+
or ENV["RESET_BETWEEN_SCENARIOS"] == "1"
|
22
|
+
if ENV["RESET_BETWEEN_SCENARIOS"] == "1"
|
23
|
+
log "New scenario - reinstalling apps"
|
24
|
+
else
|
25
|
+
log "First scenario in feature - reinstalling apps"
|
26
|
+
end
|
27
|
+
|
28
|
+
uninstall_apps
|
29
|
+
install_app(ENV["TEST_APP_PATH"])
|
30
|
+
install_app(ENV["APP_PATH"])
|
31
|
+
|
32
|
+
FeatureNameMemory.feature_name = feature_name
|
33
|
+
FeatureNameMemory.invocation = 1
|
34
|
+
else
|
35
|
+
FeatureNameMemory.invocation += 1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
FeatureNameMemory = Class.new
|
40
|
+
class << FeatureNameMemory
|
41
|
+
@feature_name = nil
|
42
|
+
attr_accessor :feature_name, :invocation
|
43
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Feature: Example iOS
|
2
|
+
# This feature will only be executed when the ios profile is loaded
|
3
|
+
# You can rename this file and update its contents or delete it and create new features
|
4
|
+
|
5
|
+
Background:
|
6
|
+
# Insert the steps
|
7
|
+
|
8
|
+
Scenario: First Scenario
|
9
|
+
# Insert the steps
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'calabash-cucumber/ibase'
|
2
|
+
|
3
|
+
class IOSScreenBase < Calabash::IBase
|
4
|
+
|
5
|
+
def self.element(element_name, &block)
|
6
|
+
define_method(element_name.to_s, *block)
|
7
|
+
end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
alias :value :element
|
11
|
+
alias :action :element
|
12
|
+
alias :trait :element
|
13
|
+
end
|
14
|
+
|
15
|
+
element(:loading_screen) { 'LOADING' }
|
16
|
+
|
17
|
+
# The progress bar of the application is a custom view
|
18
|
+
def wait_for_progress
|
19
|
+
wait_for { element_does_not_exist "* marked:'#{loading_screen}'" }
|
20
|
+
end
|
21
|
+
|
22
|
+
def has_text?(text)
|
23
|
+
!query("* {text CONTAINS[c] '#{text}'}").empty? or !query("* {accessibilityLabel CONTAINS[c] '#{text}'}").empty?
|
24
|
+
end
|
25
|
+
|
26
|
+
def drag_to direction
|
27
|
+
|
28
|
+
# iOS swipe command doesn't work.
|
29
|
+
# For a workaround we need to use the scroll function, but it only work after a swipe command
|
30
|
+
|
31
|
+
# iOS swipe :up and :down are the opposite of the Android directions
|
32
|
+
# Setting swipe_opt that will define the swipe 'force'
|
33
|
+
swipe_opt = nil
|
34
|
+
case direction
|
35
|
+
when :left
|
36
|
+
swipe_opt = {:'swipe-delta' => {:horizontal=>{:dx => 280} }, :offset => { :x => 300, :y => 300 } }
|
37
|
+
when :right
|
38
|
+
swipe_opt = {:'swipe-delta' => {:horizontal=>{:dx => 250} }, :offset => { :x => 50, :y => 300 } }
|
39
|
+
when :up
|
40
|
+
direction = :down
|
41
|
+
swipe_opt = {:'swipe-delta' => {:vertical=>{:dy => 200} }, :offset => { :x => 160, :y => 100 } }
|
42
|
+
when :down
|
43
|
+
direction = :up
|
44
|
+
swipe_opt = {:'swipe-delta' => {:vertical=>{:dy => 200} }, :offset => { :x => 160, :y => 400 } }
|
45
|
+
end
|
46
|
+
|
47
|
+
swipe(direction, swipe_opt)
|
48
|
+
|
49
|
+
sleep(1)
|
50
|
+
end
|
51
|
+
|
52
|
+
# In the iOS, an element could be found from its text or its accessibilityLabel
|
53
|
+
# so this function looks for these two properties on the screen. When the query
|
54
|
+
# looks for just a part of the text (CONTAINS[c]) then we need to specify if
|
55
|
+
# we will look in accessibilityLabel or in any other propertie (marked)
|
56
|
+
def ios_element_exists? query
|
57
|
+
second_query = nil
|
58
|
+
|
59
|
+
if query.include? "marked"
|
60
|
+
second_query = query.gsub( 'marked', 'accessibilityLabel' )
|
61
|
+
end
|
62
|
+
|
63
|
+
if query.include? "accessibilityLabel"
|
64
|
+
second_query = query.gsub( 'accessibilityLabel', 'marked' )
|
65
|
+
end
|
66
|
+
|
67
|
+
if second_query.nil?
|
68
|
+
return element_exists(query)
|
69
|
+
else
|
70
|
+
element_exists(query) or element_exists(second_query)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
def drag_until_element_is_visible_with_special_query direction, element
|
76
|
+
drag_until_element_is_visible direction, element, "* {accessibilityLabel CONTAINS[c] '#{element}'}"
|
77
|
+
end
|
78
|
+
|
79
|
+
def drag_until_element_is_visible direction, element, query = nil, limit = 15
|
80
|
+
i = 0
|
81
|
+
|
82
|
+
element_query = ""
|
83
|
+
if query.nil?
|
84
|
+
element_query = "* marked:'#{element}'"
|
85
|
+
else
|
86
|
+
element_query = query
|
87
|
+
end
|
88
|
+
|
89
|
+
sleep(1)
|
90
|
+
while( !ios_element_exists?(element_query) and i < limit) do
|
91
|
+
drag_to direction
|
92
|
+
i = i + 1
|
93
|
+
end
|
94
|
+
|
95
|
+
raise ("Executed #{limit} moviments #{direction.to_s} and the element '#{element}' was not found on this view!") unless i < limit
|
96
|
+
end
|
97
|
+
|
98
|
+
def drag_for_specified_number_of_times direction, times
|
99
|
+
times.times do
|
100
|
+
drag_to direction
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def is_on_page? page_text
|
105
|
+
begin
|
106
|
+
wait_for(:timeout => 5) { has_text? page_text }
|
107
|
+
rescue
|
108
|
+
raise "Unexpected Page. Expected was: '#{page_text}'"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def enter text, element, query = nil
|
113
|
+
if query.nil?
|
114
|
+
query( "* marked:'#{element}'", {:setText => text} )
|
115
|
+
else
|
116
|
+
query( query, {:setText => text} )
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def touch_screen_element element
|
121
|
+
begin
|
122
|
+
wait_for(:timeout => 5) { element_exists("* marked:'#{element}'") }
|
123
|
+
touch "* marked:'#{element}'"
|
124
|
+
rescue
|
125
|
+
raise "Element #{element} not found on the view"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def touch_element_by_index id, index
|
130
|
+
wait_for(:timeout => 5) { element_exists("* marked:'#{id}' index:#{index}") }
|
131
|
+
touch("* marked:'#{id}' index:#{index}")
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,84 @@
|
|
1
|
+
########################################
|
2
|
+
# #
|
3
|
+
# Important Note #
|
4
|
+
# #
|
5
|
+
# When running calabash-ios tests at #
|
6
|
+
# www.xamarin.com/test-cloud #
|
7
|
+
# the methods invoked by #
|
8
|
+
# CalabashLauncher are overriden. #
|
9
|
+
# It will automatically ensure #
|
10
|
+
# running on device, installing apps #
|
11
|
+
# etc. #
|
12
|
+
# #
|
13
|
+
########################################
|
14
|
+
|
15
|
+
require 'calabash-cucumber/launcher'
|
16
|
+
|
17
|
+
# APP_BUNDLE_PATH = "~/Library/Developer/Xcode/DerivedData/??/Build/Products/Calabash-iphonesimulator/??.app"
|
18
|
+
# You may uncomment the above to overwrite the APP_BUNDLE_PATH
|
19
|
+
# However the recommended approach is to let Calabash find the app itself
|
20
|
+
# or set the environment variable APP_BUNDLE_PATH
|
21
|
+
|
22
|
+
Before('@reinstall') do |scenario|
|
23
|
+
reinstall_app
|
24
|
+
end
|
25
|
+
|
26
|
+
Before do |scenario|
|
27
|
+
|
28
|
+
# If the scenario is outline, to get the feature title we have to access a different attribute of the variable scenario,
|
29
|
+
# so this function changes the value of the scenario variable so we don't have to do this on the verification step below
|
30
|
+
@scenario_is_outline = (scenario.class == Cucumber::Ast::OutlineTable::ExampleRow)
|
31
|
+
if @scenario_is_outline
|
32
|
+
scenario = scenario.scenario_outline
|
33
|
+
end
|
34
|
+
# Looks if is a new feature that will be executed
|
35
|
+
if ENV['FEATURE_NAME'] != scenario.feature.title # ENV['FEATURE_NAME'] is just an aux created to store the feature name
|
36
|
+
reinstall_app # always reinstall the app before a the execution of a new feature
|
37
|
+
ENV['FEATURE_NAME'] = scenario.feature.title
|
38
|
+
end
|
39
|
+
|
40
|
+
@calabash_launcher = Calabash::Cucumber::Launcher.new
|
41
|
+
unless @calabash_launcher.calabash_no_launch?
|
42
|
+
@calabash_launcher.relaunch
|
43
|
+
@calabash_launcher.calabash_notify(self)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
After do |scenario|
|
49
|
+
unless @calabash_launcher.calabash_no_stop?
|
50
|
+
calabash_exit
|
51
|
+
if @calabash_launcher.active?
|
52
|
+
@calabash_launcher.stop
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
at_exit do
|
58
|
+
launcher = Calabash::Cucumber::Launcher.new
|
59
|
+
if launcher.simulator_target?
|
60
|
+
launcher.simulator_launcher.stop unless launcher.calabash_no_stop?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Install or reinstall the app on the device
|
65
|
+
def reinstall_app
|
66
|
+
|
67
|
+
system( "echo 'Installing the app...'" )
|
68
|
+
|
69
|
+
# Trying to reinstall the app
|
70
|
+
success = system "ios-deploy -r -b #{ENV['APP_BUNDLE_PATH']} -i #{ENV['DEVICE_TARGET']} -t 5 > /dev/null"
|
71
|
+
|
72
|
+
# If the app is not installed the above command will throw an error
|
73
|
+
# So we just install the app
|
74
|
+
if !success
|
75
|
+
success = system "ios-deploy -b #{ENV['APP_BUNDLE_PATH']} -i #{ENV['DEVICE_TARGET']} -t 5 > /dev/null"
|
76
|
+
if !success # If there is any error raises an exception
|
77
|
+
raise 'Error. Could not install the app.'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
system( "echo 'Installed.'" )
|
82
|
+
|
83
|
+
sleep(3) # Gives to the iphone a time to finish the installation of the app
|
84
|
+
end
|
File without changes
|
@@ -0,0 +1,39 @@
|
|
1
|
+
######### GIVEN #########
|
2
|
+
|
3
|
+
Given(/^I (?:drag|dragged) the screen (down|up|left|right) until I see the element "(.*?)"$/) do |direction, element|
|
4
|
+
@page.drag_until_element_is_visible_with_special_query direction.to_sym, element
|
5
|
+
end
|
6
|
+
|
7
|
+
Given(/^I am on a page that contains '(.*?)'$/) do |page_text|
|
8
|
+
@page.is_on_page? page_text
|
9
|
+
end
|
10
|
+
|
11
|
+
######### WHEN #########
|
12
|
+
|
13
|
+
When(/^I drag the screen (left|right|down|up) (\d+) times$/) do |direction, times|
|
14
|
+
@page.drag_for_specified_number_of_times(direction.to_sym, times.to_i)
|
15
|
+
end
|
16
|
+
|
17
|
+
When(/^I (?:touch|touched) the "(.*?)" element$/) do |element|
|
18
|
+
@page.touch_screen_element element
|
19
|
+
end
|
20
|
+
|
21
|
+
When(/^I drag the screen (down|up|left|right)$/) do |direction|
|
22
|
+
@page.drag_to direction.to_sym
|
23
|
+
end
|
24
|
+
|
25
|
+
######### THEN #########
|
26
|
+
|
27
|
+
Then(/^I (?:wait|waited) for the progress bar to vanish$/) do
|
28
|
+
# wait_for_progress is a method of the base class, so doesn't matter what is the value
|
29
|
+
# of the @page variable, because all screens will have this method
|
30
|
+
@page.wait_for_progress
|
31
|
+
end
|
32
|
+
|
33
|
+
Then(/^I should see the page '(.*?)'$/) do |page_text|
|
34
|
+
@page.is_on_page? page_text
|
35
|
+
end
|
36
|
+
|
37
|
+
Then(/^I should see a page that contains '(.*?)'$/) do |page_text|
|
38
|
+
@page.is_on_page? page_text
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cs-bdd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oscar Tanner
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: A simple gem to generate all the folder and files needed to create an
|
42
|
+
android and iOS calabash project.
|
43
|
+
email:
|
44
|
+
- oscar.tanner@concretesolutions.com.br
|
45
|
+
executables:
|
46
|
+
- cs-bdd
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- bin/cs-bdd
|
56
|
+
- bin/cs-bdd-generate.rb
|
57
|
+
- bin/cs-bdd-helpers.rb
|
58
|
+
- cs-bdd.gemspec
|
59
|
+
- lib/cs/bdd.rb
|
60
|
+
- lib/cs/bdd/version.rb
|
61
|
+
- lib/examples/example.feature
|
62
|
+
- lib/examples/example_screen.rb
|
63
|
+
- lib/examples/example_steps.rb
|
64
|
+
- lib/skeleton/.gitignore
|
65
|
+
- lib/skeleton/README.md
|
66
|
+
- lib/skeleton/config/cucumber.yml
|
67
|
+
- lib/skeleton/config/scripts/android/run_tests_all_devices.sh
|
68
|
+
- lib/skeleton/config/scripts/ios/build_app.sh
|
69
|
+
- lib/skeleton/config/scripts/ios/devices
|
70
|
+
- lib/skeleton/config/scripts/ios/run_tests_all_devices.sh
|
71
|
+
- lib/skeleton/features/android/android_screen_base.rb
|
72
|
+
- lib/skeleton/features/android/features/.gitkeep
|
73
|
+
- lib/skeleton/features/android/features/android.feature
|
74
|
+
- lib/skeleton/features/android/screens/example_screen.rb
|
75
|
+
- lib/skeleton/features/android/steps_definition/.gitkeep
|
76
|
+
- lib/skeleton/features/android/support/app_installation_hooks.rb
|
77
|
+
- lib/skeleton/features/android/support/app_life_cycle_hooks.rb
|
78
|
+
- lib/skeleton/features/android/support/hooks.rb
|
79
|
+
- lib/skeleton/features/example.feature
|
80
|
+
- lib/skeleton/features/ios/features/.gitkeep
|
81
|
+
- lib/skeleton/features/ios/features/ios.feature
|
82
|
+
- lib/skeleton/features/ios/ios_screen_base.rb
|
83
|
+
- lib/skeleton/features/ios/screens/example_screen.rb
|
84
|
+
- lib/skeleton/features/ios/steps_definition/.gitkeep
|
85
|
+
- lib/skeleton/features/ios/support/01_launch.rb
|
86
|
+
- lib/skeleton/features/ios/support/02_pre_stop_hooks.rb
|
87
|
+
- lib/skeleton/features/step_definitions/base_steps.rb
|
88
|
+
- lib/skeleton/features/support/env.rb
|
89
|
+
homepage: https://github.com/CSOscarTanner/cs-bdd
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.4.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Generates an android and iOS calabash project.
|
113
|
+
test_files: []
|