sunomono 0.3.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +82 -24
  3. data/SUNOMONO_APPIUM.md +18 -0
  4. data/SUNOMONO_CALABASH.md +19 -0
  5. data/lib/helpers/sunomono_helpers.rb +19 -0
  6. data/lib/{skeleton → skeleton_appium}/.gitignore +0 -0
  7. data/lib/skeleton_appium/Gemfile +8 -0
  8. data/lib/{skeleton → skeleton_appium}/README.md +0 -0
  9. data/lib/{skeleton → skeleton_appium}/config/cucumber.yml +0 -0
  10. data/lib/{skeleton → skeleton_appium}/config/email/template.html +0 -0
  11. data/lib/{skeleton → skeleton_appium}/config/scripts/android/run_tests_all_devices.sh +0 -0
  12. data/lib/{skeleton → skeleton_appium}/config/scripts/android/start_emulators.sh +0 -0
  13. data/lib/{skeleton → skeleton_appium}/config/scripts/android/stop_emulators.sh +0 -0
  14. data/lib/{skeleton → skeleton_appium}/config/scripts/break_build_if_failed.sh +0 -0
  15. data/lib/{skeleton → skeleton_appium}/config/scripts/check_if_tests_failed.sh +0 -0
  16. data/lib/{skeleton → skeleton_appium}/config/scripts/ios/build_app.rb +0 -0
  17. data/lib/{skeleton → skeleton_appium}/config/scripts/ios/build_app.yml +0 -0
  18. data/lib/{skeleton → skeleton_appium}/config/scripts/ios/devices.txt +0 -0
  19. data/lib/{skeleton → skeleton_appium}/config/scripts/ios/run_tests_all_devices.sh +0 -0
  20. data/lib/{skeleton → skeleton_appium}/features/android/features/.gitkeep +0 -0
  21. data/lib/{skeleton → skeleton_appium}/features/android/screens/.gitkeep +0 -0
  22. data/lib/{skeleton → skeleton_appium}/features/android/step_definitions/.gitkeep +0 -0
  23. data/lib/{skeleton → skeleton_appium}/features/android/support/hooks.rb +0 -0
  24. data/lib/{skeleton → skeleton_appium}/features/ios/features/.gitkeep +0 -0
  25. data/lib/{skeleton → skeleton_appium}/features/ios/screens/.gitkeep +0 -0
  26. data/lib/{skeleton → skeleton_appium}/features/ios/step_definitions/.gitkeep +0 -0
  27. data/lib/skeleton_appium/features/support/android/appium.txt +4 -0
  28. data/lib/skeleton_appium/features/support/env.rb +21 -0
  29. data/lib/{skeleton → skeleton_appium}/features/support/exceptions.rb +0 -0
  30. data/lib/{skeleton/features/ios/support/02_pre_stop_hooks.rb → skeleton_appium/features/support/hooks.rb} +0 -0
  31. data/lib/skeleton_appium/features/support/ios/appium.txt +5 -0
  32. data/lib/{skeleton → skeleton_appium}/screenshots/android/.gitkeep +0 -0
  33. data/lib/{skeleton → skeleton_appium}/screenshots/ios/.gitkeep +0 -0
  34. data/lib/skeleton_calabash/.gitignore +9 -0
  35. data/lib/{skeleton → skeleton_calabash}/Gemfile +0 -0
  36. data/lib/skeleton_calabash/README.md +165 -0
  37. data/lib/skeleton_calabash/config/cucumber.yml +7 -0
  38. data/lib/skeleton_calabash/config/email/template.html +14 -0
  39. data/lib/{skeleton → skeleton_calabash}/config/load_classes.rb +0 -0
  40. data/lib/skeleton_calabash/config/scripts/android/run_tests_all_devices.sh +41 -0
  41. data/lib/skeleton_calabash/config/scripts/android/start_emulators.sh +52 -0
  42. data/lib/skeleton_calabash/config/scripts/android/stop_emulators.sh +13 -0
  43. data/lib/skeleton_calabash/config/scripts/break_build_if_failed.sh +6 -0
  44. data/lib/skeleton_calabash/config/scripts/check_if_tests_failed.sh +11 -0
  45. data/lib/skeleton_calabash/config/scripts/ios/build_app.rb +71 -0
  46. data/lib/skeleton_calabash/config/scripts/ios/build_app.yml +13 -0
  47. data/lib/skeleton_calabash/config/scripts/ios/devices.txt +4 -0
  48. data/lib/skeleton_calabash/config/scripts/ios/run_tests_all_devices.sh +57 -0
  49. data/lib/skeleton_calabash/features/android/features/.gitkeep +0 -0
  50. data/lib/skeleton_calabash/features/android/screens/.gitkeep +0 -0
  51. data/lib/skeleton_calabash/features/android/step_definitions/.gitkeep +0 -0
  52. data/lib/{skeleton → skeleton_calabash}/features/android/support/app_installation_hooks.rb +0 -0
  53. data/lib/{skeleton → skeleton_calabash}/features/android/support/app_life_cycle_hooks.rb +0 -0
  54. data/lib/skeleton_calabash/features/android/support/hooks.rb +0 -0
  55. data/lib/skeleton_calabash/features/ios/features/.gitkeep +0 -0
  56. data/lib/skeleton_calabash/features/ios/screens/.gitkeep +0 -0
  57. data/lib/skeleton_calabash/features/ios/step_definitions/.gitkeep +0 -0
  58. data/lib/{skeleton → skeleton_calabash}/features/ios/support/01_launch.rb +0 -0
  59. data/lib/skeleton_calabash/features/ios/support/02_pre_stop_hooks.rb +0 -0
  60. data/lib/{skeleton → skeleton_calabash}/features/support/env.rb +0 -0
  61. data/lib/skeleton_calabash/features/support/exceptions.rb +11 -0
  62. data/lib/skeleton_calabash/screenshots/android/.gitkeep +0 -0
  63. data/lib/skeleton_calabash/screenshots/ios/.gitkeep +0 -0
  64. data/lib/sunomono/version.rb +1 -1
  65. data/lib/sunomono.rb +134 -47
  66. data/lib/templates/appium_base_screen.tt +13 -0
  67. data/lib/templates/appium_base_steps.tt +46 -0
  68. data/lib/templates/appium_screen.tt +7 -0
  69. data/spec/sunomono_test.rb +33 -31
  70. metadata +65 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 812541d3339c2da0aebd704bb947ff5440e66973
4
- data.tar.gz: addd53f13c8d9b96203d7cddd9fad2c802800c35
3
+ metadata.gz: c2004c5b090a5d6ad75bba706b0b8ec7f56efc36
4
+ data.tar.gz: 4ffb96f15db0a129f681d89aa4d348f0e2eab48d
5
5
  SHA512:
6
- metadata.gz: 33e7fca8f285101e3a1ae14130ba262536e65e4cc05263ee5aa1080b04f96ca60c2f6f4d76e2674b99149762c7a1fbcf2089c800e5aef3d61f44dc86df22aa48
7
- data.tar.gz: 706956af6e7a3aeba067e01e10c41163dd8d4bfb2098985372ae85d58ccfd48f55ac901e2a14f46c578d4592f449df5fd0573df8e5c75734fd2d93ae27ca9ef5
6
+ metadata.gz: 3c1a32996b059a4ac2eac72bab7823f4856c955b62abd4e53901eaf9063d09cbdd19aca0ea287b9b288a6caf0de88da2ea52d13eb92fcbee24e8cd15e29d8d06
7
+ data.tar.gz: e4818940ec114d4f016f80080ec1ed4302cf07dd05aabedf2f6b1bce958e6486e319305795c94134e1e10b387fe37909edc21311071c8080310e5a4d3570ad34
data/README.md CHANGED
@@ -4,25 +4,13 @@
4
4
 
5
5
  > ***The new version of [cs-bdd](https://rubygems.org/gems/cs-bdd) gem. cs-bdd was deprecated and will be yanked in the future. Always refer to sunomono from now on.***
6
6
 
7
- A simple gem to generate all files needed in a project that will support calabash for both Android and iOS.
7
+ A simple gem to generate all files needed in a project that will support calabash and appium for both Android and iOS.
8
8
 
9
9
  iOS Build script works only with iOS SDK 9.2 or newer
10
10
 
11
- [Calabash](http://calaba.sh/) uses cucumber to support functional tests in Android and iOS and has one gem for each Platform:
11
+ Sunomono(calabash) documentation : [(link)](https://github.com/concretesolutions/sunomono/SUNOMONO_CALABASH.md)
12
12
 
13
- > calabash-android (for Android) [(link)](https://github.com/calabash/calabash-android)
14
-
15
- > calabash-cucumber (for iOS) [(link)](https://github.com/calabash/calabash-ios)
16
-
17
- The project structure is based on [this site](http://rubygemtsl.com/2014/01/06/designing-maintainable-calabash-tests-using-screen-objects-2). The structure is based on three layers: features, steps and screens.
18
-
19
- 1. Features: Contains all the features of the project, this features are Platform independent and will run for Android and iOS tests;
20
- 2. Steps: Contains all the steps implementations. This steps are Platform independent and will run for Android and iOS tests;
21
- 3. Screens: Contains all the Android and iOS screens. A screen must contain an identification, the declaration of all the elements of the screen and the declaration of its actions. This layer is Platform dependent. This occurs because, in almost every project, the identification of the elements varies between the Platforms. One example is that in Android almost all elements have an id, but in iOS the most common is to identify the elements by accessibility label. The Platform dependent screens must have the same name and same methods signatures. This will allow your steps to be unique between platforms
22
-
23
- > One example of this structure can be found in the generated files (see Usage) on the file base_steps.rb. This file implements some common steps to help you start your tests and show you how to uses the Platform dependent screens
24
-
25
- > In my experience with tests I saw some cases that we will need to test features that are Platform dependent, like screens that send SMS which will only apper in Android apps. When this happen, the generated structure has Features and Steps that are Platform dependent and can be found inside the folder `features/android` and `features/ios` of the generated project.
13
+ Sunomono(appium) documentation : [(link)](https://github.com/concretesolutions/sunomono/SUNOMONO_APPPIUM.md)
26
14
 
27
15
  ## Installation
28
16
 
@@ -53,13 +41,19 @@ To see the gem version type:
53
41
  To generate a project that support both Android and iOS features type:
54
42
 
55
43
  ```
56
- suno new ProjectName
44
+ suno new calabash ProjectName
45
+ ```
46
+
47
+ or
48
+
49
+ ```
50
+ suno new appium Project Name
57
51
  ```
58
52
 
59
53
  This command will create a folder named ProjectName in the current directory and will create all the needed files. This gem support localizations. To create a localized project, in Portuguese, type:
60
54
 
61
55
  ```
62
- suno new ProjectName --lang=pt
56
+ suno new Framework(calabash or appium) ProjectName --lang=pt
63
57
  ```
64
58
 
65
59
  If you use Windows, to avoid encoding problems, run the following command in cmd:
@@ -91,13 +85,22 @@ There are nine generators that are responsible to create the templates for Featu
91
85
  ```
92
86
  The feature generator will create a Platform independent feature and its files. So this command will create the FeatureName.feature file inside the folder `feature`, the file FeatureName_steps.rb inside the folder `features/step_definitions`, the files FeatureName_screen.rb inside the folders `features/android/screens` and `features/ios/screens`.
93
87
 
88
+ To create calabash based files:
94
89
 
95
90
  ```
96
- suno generate android-feature AndroidFeatureName
97
- suno generate ios-feature iOSFeatureName
91
+ suno generate calabash android-feature AndroidFeatureName
92
+ suno generate calabash ios-feature iOSFeatureName
98
93
  ```
99
- The aFeature and iFeature generator will create an Platform dependent feature. For example, the aFeature generator will create the AndroidFeatureName.feature file inside the folder `features/android/features`, the file AndroidFeatureName_steps.rb inside the folder `features/androd/step_definitions` and the screen file AndroidFeatureName_screen.rb inside the folder `features/android/screens`.
100
94
 
95
+ To create appium based files:
96
+
97
+ ```
98
+ suno generate appium android-feature AndroidFeatureName
99
+ suno generate appium ios-feature iOSFeatureName
100
+
101
+ ```
102
+
103
+ The aFeature and iFeature generator create a dependent feature for each platform. For example, aFeature generates the AndroidFeatureName.feature file inside the folder features/android/features, the file AndroidFeatureName_steps.rb inside the folder features/androd/step_definitions and the screen file AndroidFeatureName_screen.rb inside the folder features/android/screens.
101
104
 
102
105
  Don't forget about internationalization. All the generators accept the option `--lang=pt` or with some other language.
103
106
 
@@ -106,14 +109,14 @@ Don't forget about internationalization. All the generators accept the option `-
106
109
  ```
107
110
  suno generate step StepName
108
111
  ```
109
- The step generator will create a Platform independent step file named StepName_steps.rb in the folder `features/step_definitions`
110
112
 
113
+ Another command creates an independent step file named StepName_steps.rb inside the folder features/step_definitions for each platform
111
114
 
112
115
  ```
113
116
  suno generate android-step AndroidStepName
114
117
  ```
115
- The android-step generator will create an Android step file named AndroidStepName_steps.rb in the folder `features/android/step_definitions`
116
118
 
119
+ For Android, it creates a step file named AndroidStepName_steps.rb inside features/android/step_definitions
117
120
 
118
121
  ```
119
122
  suno generate ios-step iOSStepName
@@ -129,13 +132,68 @@ The iStep generator will create an iOS step file name iOSStepName_steps.rb in th
129
132
  ```
130
133
  The screen generator will create both Platform dependent screens in the folders `features/android/screens` and `features/ios/screens`.
131
134
 
135
+ To create calabash based files:
136
+
137
+ ```
138
+ suno generate calabash android-screen AndroidScreenName
139
+ suno generate calabash ios-screen iOSScreenName
140
+ ```
141
+
142
+ To create appium based files:
132
143
 
133
144
  ```
134
- suno generate android-screen AndroidScreenName
135
- suno generate ios-screen iOSScreenName
145
+ suno generate appium android-screen AndroidScreenName
146
+ suno generate appium ios-screen iOSScreenName
136
147
  ```
148
+
137
149
  The android-screen and ios-screen will create only the Android and iOS dependent screens respectively.
138
150
 
151
+ ## Load Classes
152
+ **It works only calabash project**
153
+ ### Usage
154
+
155
+ The load classes has been living in:
156
+
157
+ ```
158
+ features/config/load_classes.rb
159
+ ```
160
+
161
+ load_classes.rb provides a easy way to test your methods under development
162
+
163
+
164
+ Use the calabash-android console mode
165
+
166
+ ````
167
+ bundle exec calabash-android console -p android feature/
168
+ ````
169
+
170
+ or
171
+
172
+ ````
173
+ bundle exec calabash-ios console -p ios feature/
174
+ ````
175
+
176
+ To load all .rb classes, run the following command on terminal
177
+
178
+ ````
179
+ load 'config/load_classes.rb'
180
+ ````
181
+
182
+ Now you got all .rb files loaded
183
+
184
+ Next step is to create a new instance of the class to test your methods
185
+
186
+ ```
187
+ @foo = page(fooScreen)
188
+ ```
189
+
190
+ To use the methods, just call the method and enjoy
191
+
192
+ ```
193
+ @foo.fill_data
194
+ ```
195
+
196
+
139
197
  ## Continuous Integration (CI)
140
198
 
141
199
  The project contains a lot of scripts that will help you to configure you CI server.
@@ -0,0 +1,18 @@
1
+ # Sunomono Appium documentation
2
+
3
+ [Appium](http://appium.io/) Appium uses Selenium to functional tests on Android and on iOS:
4
+
5
+ The project structure is based on this [project](https://github.com/gricsi/cross-platform-appium-cucumber-test-example). The structure is based on three layers: features, steps, screens and modules.
6
+
7
+
8
+ 1. Features: Contains all the features of the project, this features are Platform independent and will run for Android and iOS tests;
9
+ 2. Steps: Contains all the steps implementations. This steps are Platform independent and will run for Android and iOS tests;
10
+ 3. Screens: Contains all the Android and iOS screens. A screen must contain an identification, the declaration of all the elements of the screen and the declaration of its actions. This layer is Platform dependent. This occurs because, in almost every project, the identification of the elements varies between the Platforms. One example is that in Android almost all elements have an id, but in iOS the most common is to identify the elements by accessibility label. The Platform dependent screens must have the same name and same methods signatures. This will allow your steps to be unique between platforms
11
+ 4. Modules: Contains all the methods commons between the features e.g(LoginScreen(android) and LoginScreen(ios) contains the elements of the screens and different methods and interaction between platforms), the module contains the method with the same behavior on platforms
12
+
13
+ ## Appium server
14
+
15
+ RakeFile contains any tips to start the appium server and run your tests
16
+
17
+
18
+
@@ -0,0 +1,19 @@
1
+ # Sunomono Calabash documentation
2
+
3
+ [Calabash](http://calaba.sh/) uses cucumber to support functional tests in Android and iOS and has one gem for each Platform:
4
+
5
+ > calabash-android (for Android) [(link)](https://github.com/calabash/calabash-android)
6
+
7
+ > calabash-cucumber (for iOS) [(link)](https://github.com/calabash/calabash-ios)
8
+
9
+ The project structure is based on [this site](http://rubygemtsl.com/2014/01/06/designing-maintainable-calabash-tests-using-screen-objects-2).The structure is based on three layers: features, steps and screens.
10
+
11
+ 1. Features: Contains all the project features, which are Platform independent and will run for Android and iOS tests;
12
+ 2. Steps: Contains all the steps implementations. These steps are Platform independent and will run for Android and iOS tests;
13
+ 3. Screens: Contains all the Android and iOS screens. A screen must contain an identification, the declaration of all the elements of the screen and the declaration of its actions. This layer is Platform dependent. This happens because of, in almost every project, the identification of the elements varies between the Platforms. One example is that on Android most elements have an id, but on iOS it’s common to identify the elements by accessibility label. The Platform dependent screens must have the same name and the same methods signatures. This will allow your steps to be unique between platforms
14
+
15
+ > One example of this structure can be found in the generated files (see Usage) on the file base_steps.rb. This file implements some common steps to help you start your tests and show you how to uses the Platform dependent screens
16
+
17
+ > In my experience with tests I saw some cases that we will need to test features that are Platform dependent, like screens that send SMS which will only apper in Android apps. When this happen, the generated structure has Features and Steps that are Platform dependent and can be found inside the folder `features/android` and `features/ios` of the generated project.
18
+
19
+
@@ -58,6 +58,18 @@ def create_screen_file(name, platform)
58
58
  ), opts)
59
59
  end
60
60
 
61
+ def create_appium_screen_file(name, platform)
62
+ # options used to generate the file in the template function
63
+ opts = { name: camelize(name), platform: platform }
64
+
65
+ # Thor creates a file based on the templates/appium_screen.tt template
66
+ template('appium_screen',
67
+ File.join(
68
+ FileUtils.pwd, 'features', platform.downcase, 'screens',
69
+ "#{name.downcase}_screen.rb"
70
+ ), opts)
71
+ end
72
+
61
73
  def camelize(string)
62
74
  camelized = ''
63
75
 
@@ -134,3 +146,10 @@ def create_screen_shot_dirs(dir)
134
146
  Dir.mkdir File.join(dir, 'screenshots', 'ios')
135
147
  Dir.mkdir File.join(dir, 'screenshots', 'android')
136
148
  end
149
+
150
+ def framework_avaliable?(framework)
151
+ if framework.downcase != 'calabash' && framework.downcase != 'appium'
152
+ puts 'Invalid framework choice calabash or appium'
153
+ exit 1
154
+ end
155
+ end
File without changes
@@ -0,0 +1,8 @@
1
+ # Gemfile to help setting up the initial development environment
2
+ source 'https://rubygems.org'
3
+
4
+ gem 'appium_lib'
5
+ gem 'appium_console'
6
+ gem "cucumber"
7
+ gem 'sunomono'
8
+ gem 'pry'
File without changes
@@ -0,0 +1,4 @@
1
+ [caps]
2
+ platformName = "Platform name e.g Android"
3
+ deviceName = "Device name e.g Nexus_5 or device ID"
4
+ app = "path to apk"
@@ -0,0 +1,21 @@
1
+ require 'pry'
2
+ require 'appium_lib'
3
+ require_relative File.expand_path('../../base_screen/base_screen.rb', __FILE__)
4
+
5
+
6
+ # Class to not pollute 'Object' class with appium methods
7
+ class AppiumWorld
8
+ end
9
+
10
+ if ENV['PLATAFORM'] == 'android'
11
+ caps = Appium.load_appium_txt file: File.expand_path('../android/appium.txt', __FILE__), verbose: true
12
+ else
13
+ caps = Appium.load_appium_txt file: File.expand_path('../ios/appium.txt', __FILE__), verbose: true
14
+ end
15
+
16
+ Appium::Driver.new(caps)
17
+ Appium.promote_appium_methods Object
18
+
19
+ World do
20
+ AppiumWorld.new
21
+ end
@@ -0,0 +1,5 @@
1
+ [caps]
2
+ platformName = "plataform name e.g = iOS"
3
+ platformVersion = "platform version e.g = sdk version"
4
+ deviceName = "device name e.g iPhone 6"
5
+ app = "path to apk or ipa"
@@ -0,0 +1,9 @@
1
+ .irb-history
2
+ reports/*
3
+ test_servers/*
4
+ .DS_Store
5
+ screenshot*.png
6
+ screenshots/android/*
7
+ !screenshots/android/.*
8
+ screenshots/ios/*
9
+ !screenshots/ios/.*
File without changes
@@ -0,0 +1,165 @@
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 calabash-android
28
+ ```
29
+
30
+ **Warning!**
31
+
32
+ The gem **`calabash-android`** can install the beta version of the cucumber gem.
33
+ This gem brokes the execution of the calabash. After the installation of calabash-android, check your installed gems with the command `gem list | grep cucumber` and install the stable version of the cucumber gem (command: `gem install cucumber`) and remove the beta version (command: `gem uninstall cucumber`), if that is the case.
34
+
35
+ ## Running the tests
36
+ To run the android tests, you need to:
37
+
38
+ 1. Open the Android AVD
39
+ 2. Open the terminal on the tests folder
40
+ 3. Execute the command:
41
+
42
+ ```
43
+ calabash-android run features/app-QA.apk -p android
44
+ ```
45
+
46
+
47
+ > To run in a computer with more than one emulator or device, use the command:
48
+ >
49
+ >```
50
+ > ADB_DEVICE_ARG=emulator-5554 calabash-android run features/app-QA.apk -p android
51
+ >```
52
+ >
53
+ >Given that 'emulator-5554' is one of the returns of the command `$ adb devices` on the terminal
54
+
55
+
56
+ > To run on all connected devices, run the script `run_tests_all_devices.sh`, located on the `config/scripts/android` folder of the project
57
+
58
+ > **!! IMPORTANT !!**
59
+
60
+ > Remember to export the WORKSPACE variable with the path of the cloned test repository
61
+
62
+ > Remember to pass the APK path as the parameter of the script
63
+ >
64
+ > ```
65
+ > ./config/scripts/android/run_tests_all_devices.sh PATH_OF_APK_FILE
66
+ >```
67
+
68
+
69
+ ## Calabash Terminal
70
+
71
+ The calabash terminal allows you to run the calabash commands without being on a test context
72
+ To open the calabash terminal, you need to:
73
+
74
+ 1. Open the Android AVD
75
+ 2. Open the terminal on the tests folder
76
+ 3. Execute the command:
77
+
78
+ ```
79
+ calabash-android console features/app-QA.apk -p android
80
+ ```
81
+
82
+ 4. Run the commands
83
+
84
+ ```
85
+ reinstall_apps
86
+ start_test_server_in_background
87
+ ```
88
+
89
+ 5. Run the commands you want to.
90
+
91
+ # iOS
92
+
93
+ ## Installing the Gems
94
+
95
+ Install the following gems
96
+
97
+ ```
98
+ gem install calabash-common calabash-cucumber
99
+ ```
100
+
101
+ ## Configuring the iOS project
102
+
103
+ 1. Run the command `pod install`
104
+ 2. Run the command `calabash-ios setup` and follow the instructions
105
+ 3. Make sure that the signing is a wildcard
106
+
107
+
108
+ ## Running the tests
109
+ To run the iOS tests in a device, you need to:
110
+
111
+ 1. Open the terminal on the tests folder
112
+ 2. Compile the project to create the .app file with the command
113
+
114
+ ```
115
+ ./config/scripts/ios/build_app.sh xcworkspace_path TargetName-cal iphoneos8.1 ConfigurationName
116
+ ```
117
+
118
+ PS.1: TargetName-cal is the name of the target created with the command `calabash-ios setup`
119
+ PS.2: iphoneos8.1 is the sdk for devices, for emulatores use iphonesimulator8.1
120
+ PS.3: Configuration name can be Dev, Debug, Release, Prod or any other configuration build
121
+ PS.4: The path to the .app file is the last output line of the above command
122
+
123
+ 3. To execute one feature, run the command
124
+
125
+ ```
126
+ APP_BUNDLE_PATH=AppFilePath DEVICE_TARGET=DeviceUUID DEVICE_ENDPOINT=CalabashServerEndpointDevice cucumber -p ios
127
+ ```
128
+
129
+ 4. To execute all the features in the configured devices run the script
130
+
131
+ ```
132
+ ./config/scripts/ios/run_tests_all_devices.sh AppFilePath
133
+ ```
134
+
135
+ PS.: Remember to configure all the connected devices on the file `./config/scripts/ios/devices`.
136
+ 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.
137
+
138
+ ## Calabash Terminal (Device)
139
+
140
+ The calabash terminal allows you to run the calabash commands without being on a test context
141
+ To open the calabash terminal, you need to:
142
+
143
+ 1. Connect the device
144
+ 2. Open the terminal on the tests folder
145
+ 3. Execute the command:
146
+
147
+ ```
148
+ APP_BUNDLE_PATH=AppFilePath DEVICE_TARGET=DeviceUUID DEVICE_ENDPOINT=CalabashServerEndpointDevice calabash-ios console
149
+ ```
150
+
151
+ 4. Run the command
152
+
153
+ ```
154
+ start_test_server_in_background
155
+ ```
156
+
157
+ 5. Run the commands you want to.
158
+
159
+ ## Pitfalls
160
+
161
+ 1. Always build the project with the device connected
162
+ 2. Ensure that the device is enabled to Development and the UI Automations is enabled on the Developer menu (Settings)
163
+ 3. If the device in pin locked, ensure that it is unlocked. If there is no pin, the calabash will automatically unlock the device
164
+ 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.
165
+ 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 SCREENSHOT_PATH=screenshots/android/ -r features/support -r features/android -r features/step_definitions --exclude features/ios
5
+
6
+
7
+ ios: PLATFORM=ios SCREENSHOT_PATH=screenshots/ios/ -r features/support -r features/ios -r features/step_definitions --exclude features/android
@@ -0,0 +1,14 @@
1
+ <html>
2
+ <head>
3
+ <meta charset="UTF-8">
4
+ <title>Project Name - Sunomono _OS_ - _STATUS_TITLE_</title>
5
+ </head>
6
+ <body>
7
+ <center>
8
+ <h1>Continuous Integration</h1>
9
+ <h2>Job Status: _JOB_NAME_, build number: #_BUILD_NUMBER_</h2>
10
+ Hello. I'm here to let you know that the tests <strong>_STATUS_</strong>.<br>
11
+ To view the reports, click <a href="http://jenkins_url/reports/_JOB_NAME_/_BUILD_NUMBER_">here.</a><br>
12
+ </center>
13
+ </body>
14
+ </html>
@@ -0,0 +1,41 @@
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
+ # $2 -> parameter to indicates the tapume to run. Can be null and can have other 2 values: must or should
8
+
9
+ ## CODE BEGIN #############################################################
10
+ [ $# -lt 1 ] && echo "Wrong number of parameters." && exit 1
11
+
12
+ # Counting the number of lines returned from the command adb devices
13
+ # This command will return at least 2 as result, because of one header line and one empty line at end
14
+ # So if the result is less than or equal 2, it means that there are no devices or emulators connected
15
+ number_of_devices=$(adb devices | wc -l)
16
+ [ $number_of_devices -le 2 ] && echo "There are no devices or emulators connected!" && exit 1
17
+
18
+ echo Inicio da execução: $(date)
19
+
20
+ # Creating the reports folder for the html format
21
+ reports_path="$WORKSPACE/reports-cal"
22
+ mkdir $reports_path
23
+
24
+ for device in $(adb devices | grep "device$" | cut -f 1)
25
+ do
26
+ cd $WORKSPACE
27
+ # Creates the reports folder
28
+ mkdir "$reports_path"/"$device"
29
+
30
+ {
31
+ ADB_DEVICE_ARG=$device calabash-android run $1 -p android SCREENSHOT_PATH="$reports_path"/"$device"/ -f 'Calabash::Formatters::Html' -o "$reports_path"/"$device"/reports.html -f junit -o "$reports_path"/"$device"
32
+ # Calabash has a problem with images relative path, the command above will replace all the images path on the
33
+ # html report file to be a relative path
34
+ sed -i.bak 's|'"$reports_path"/"$device"/'||g' "$reports_path"/"$device"/reports.html
35
+ }&
36
+
37
+ done
38
+ wait
39
+
40
+ echo Fim da execução: $(date)
41
+ ## CODE END #############################################################
@@ -0,0 +1,52 @@
1
+ #!/bin/bash
2
+ # Author: Victor Nascimento
3
+
4
+ bash stop_emulators.sh
5
+
6
+ # Suffix name of the AVD
7
+ SUFFIX="CALABASH_AVD_4."
8
+
9
+ # All $SUFFIX emulators are started
10
+ for AVD in ${HOME}/.android/avd/${SUFFIX}*.avd
11
+ do
12
+ # remove any locks that were left
13
+ rm "$AVD/*.lock" 2> /dev/null
14
+ # takes only the name of the AVD
15
+ echo $AVD
16
+ AVD="$(basename ${AVD/.avd/})"
17
+ echo starting "$AVD"...
18
+ emulator -wipe-data -gpu on -noaudio -scale 0.5 -no-boot-anim -accel on -avd "$AVD" -qemu -m 1024 -enable-kvm &
19
+ done
20
+
21
+ sleep 15
22
+ # lists all emulators with adb and check for its online state
23
+
24
+ # finds the port through adb emulator name
25
+ for porta in $(adb devices -l | grep ^emulator | cut -d " " -f 1 | cut -d - -f 2)
26
+ do
27
+ echo Searching for emulator PID for port: ${porta}
28
+ pid=$(netstat -tlnp 2> /dev/null | grep "$porta" | tr -s " " | cut -d " " -f 7 | cut -d "/" -f 1)
29
+ echo gets the AVD name from the exec command
30
+ avd=$(ps -ef | grep -v grep | grep "$pid" | egrep -o '\-avd .*' | cut -d " " -f 2)
31
+ echo AVD: ${avd}
32
+ # if name contains suffix
33
+ if echo "$avd" | grep -q "$SUFFIX"
34
+ then
35
+ echo Waiting for "emulator-${porta}:${avd}" to be ready
36
+
37
+ # Wait for online state with maximum 60 tries
38
+ COUNT=0
39
+
40
+ while adb -s "emulator-${porta}" shell getprop dev.bootcomplete | grep -q error
41
+ do
42
+ if [ "$COUNT" -eq 60 ]
43
+ then
44
+ echo "Emulator took too long to start up"
45
+ exit 1
46
+ fi
47
+
48
+ let COUNT++
49
+ sleep 1
50
+ done
51
+ fi
52
+ done