xcfit 2.0.9 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Docs/README_XCFit2.md +572 -0
- data/Gemfile.lock +2 -2
- data/README.md +182 -203
- data/homebrew/xcfit +25 -6
- data/lib/XCFit/main.rb +13 -0
- data/lib/XCFit/version.rb +1 -1
- metadata +3 -21
- data/XCFit_Templates/XCFit/Base Acceptance Testing Bundle.xctemplate/TemplateIcon.icns +0 -0
- data/XCFit_Templates/XCFit/Base Acceptance Testing Bundle.xctemplate/TemplateInfo.plist +0 -134
- data/XCFit_Templates/XCFit/Base Acceptance Testing Bundle.xctemplate/___PACKAGENAMEASIDENTIFIER___.m +0 -17
- data/XCFit_Templates/XCFit/Base Acceptance Testing Bundle.xctemplate/___PACKAGENAMEASIDENTIFIER___.swift +0 -13
- data/XCFit_Templates/XCFit/Base Acceptance Testing Bundle.xctemplate/___POD_NAME___.m +0 -25
- data/XCFit_Templates/XCFit/Base Acceptance Tests.xctemplate/AcceptanceTests-Bridging-Header.h +0 -1
- data/XCFit_Templates/XCFit/Base Acceptance Tests.xctemplate/FixtureExample.swift +0 -35
- data/XCFit_Templates/XCFit/Base Acceptance Tests.xctemplate/SlimTables.h +0 -28
- data/XCFit_Templates/XCFit/Base Acceptance Tests.xctemplate/TemplateInfo.plist +0 -155
- data/XCFit_Templates/XCFit/Base Acceptance Tests.xctemplate/___PACKAGENAMEASIDENTIFIER___-Bridging-Header.h +0 -12
- data/XCFit_Templates/XCFit/Base Acceptance Tests.xctemplate/___PACKAGENAMEASIDENTIFIER___.m +0 -33
- data/XCFit_Templates/XCFit/iOS Acceptance Testing Bundle.xctemplate/TemplateIcon-old.icns +0 -0
- data/XCFit_Templates/XCFit/iOS Acceptance Testing Bundle.xctemplate/TemplateIcon.png +0 -0
- data/XCFit_Templates/XCFit/iOS Acceptance Testing Bundle.xctemplate/TemplateIcon@2x.png +0 -0
- data/XCFit_Templates/XCFit/iOS Acceptance Testing Bundle.xctemplate/TemplateInfo.plist +0 -40
- data/XCFit_Templates/XCFit/iOS Acceptance Tests.xctemplate/TemplateIcon-old.icns +0 -0
- data/XCFit_Templates/XCFit/iOS Acceptance Tests.xctemplate/TemplateIcon.png +0 -0
- data/XCFit_Templates/XCFit/iOS Acceptance Tests.xctemplate/TemplateIcon@2x.png +0 -0
- data/XCFit_Templates/XCFit/iOS Acceptance Tests.xctemplate/TemplateInfo.plist +0 -59
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
# XCFit : Full Stack BDD in Xcode
|
7
7
|
|
8
|
-
**XCFit a.k.a ([XCUI](https://developer.apple.com/videos/play/wwdc2015/406/0), [Cucumberish](https://github.com/Ahmed-Ali/Cucumberish) and [Fitnesse](https://github.com/paulstringer/OCSlimProject) Integrations Tests) is a full stack Xcode BDD framework for [Swift](https://swift.org) iOS
|
8
|
+
**XCFit a.k.a ([XCUI](https://developer.apple.com/videos/play/wwdc2015/406/0), [Cucumberish](https://github.com/Ahmed-Ali/Cucumberish) and [Fitnesse](https://github.com/paulstringer/OCSlimProject) Integrations Tests) is a full stack Xcode BDD framework for [Swift](https://swift.org) iOS apps. XCFit allows us to write BDD Style API/Contract level, UI and Acceptance Tests with Swift in human readable language using tools like [Cucumber](https://cucumber.io/) and [Fitnesse](http://fitnesse.org/) in Xcode. We can still use Apple's brand new UI Testing framework (XCUI) under the hood of XCFit and Cucumberish. XCFit is fully automated solution for Cucumberish and Fitnesse. You can use 80(Fitnesse):20(Cucumberish) formula to automate Acceptance and UI Testing for better coverage and faster feedback. XCFit is available on [Homebrew](http://brew.sh), [RubyGem](https://rubygems.org/gems/xcfit), [CocoaPods](http://cocoadocs.org/docsets/XCFit), Carthage and Swift Package Manager.**
|
9
9
|
|
10
10
|
### XCFit
|
11
11
|
|
@@ -15,10 +15,10 @@
|
|
15
15
|
* [Tech & Software Requirements](#tech--software-requirements)
|
16
16
|
* [Installation](#installation)
|
17
17
|
* [Setup Xcode Templates](#setup-xcode-templates)
|
18
|
+
* [XCFit Swift Framework](#xcfit-swift-framework--xcui-page-object-pattern--pre-defined-steps)
|
18
19
|
* [Setting Cucumberish BDD Scenarios in Xcode](#setting-cucumberish-bdd-scenarios-in-xcode)
|
19
|
-
* [XCUI Page Object Pattern](#xcui-page-object-pattern)
|
20
20
|
* [Fitnesse for iOS: Acceptance/Contract Tests](#fitnesse-for-ios-acceptancecontract-tests)
|
21
|
-
* [Continuous Integration
|
21
|
+
* [Continuous Integration with Xcode Server](#continuous-integration-with-xcode-server)
|
22
22
|
* [XCFit: Swift Package Manager](#xcfit-swift-package-manager)
|
23
23
|
* [Quick Demo with Example App](#quick-demo-with-example-app)
|
24
24
|
* [Acknowledgements](#acknowledgements)
|
@@ -29,33 +29,40 @@
|
|
29
29
|
|
30
30
|
# XCFit Features
|
31
31
|
***
|
32
|
-
- You can now write Given When Then (Gherkin) and Decision Table in Xcode. In Short, you can do BDD in Xcode for your iOS app.
|
32
|
+
- You can now write Given When Then (Gherkin), Predefined BDD Steps and Decision Table in Xcode. In Short, you can do BDD in Xcode for your iOS app.
|
33
33
|
- You can now write/Execute all your Acceptance Tests and UI Tests using Apple's brand new programming language "Swift" in Xcode. Goodbye Appium, Calabash, Frank, KIF and Goodbye Ruby,Java, Python. It's pure Swift !!
|
34
|
-
- XCFit provides automated Xcode Target Templates for Cucumberish, Fitnesse and Page Object Pattern(XCUI) targets which reduce hectic Xcode configuration steps. It also arrange code in Xcode groups.
|
35
|
-
- XCFit will setup
|
34
|
+
- XCFit provides automated Xcode Target Templates for Cucumberish, Fitnesse and Page Object Pattern(XCUI) targets which reduce hectic Xcode configuration steps. It also arrange code in Xcode groups.
|
35
|
+
- XCFit will setup Xcode Template with skeleton code and provide BDD Style Steps with Swift Framework which is available on Cocoapods, Carthage and Swift Package Manager.
|
36
36
|
|
37
37
|
|
38
|
-
### XCFIT
|
39
|
-
|
38
|
+
### XCFIT Templates & Related Frameworks
|
39
|
+
|
40
|
+
* **XCFit Swift Framework with Pre-defined BDD Steps and Page Object Pattern Templates**
|
40
41
|
|
41
|
-
XCFit setup [
|
42
|
-
|
42
|
+
XCFit setup [Page Object Pattern](http://martinfowler.com/bliki/PageObject.html) for Apple's [XCUI Test](https://developer.apple.com/videos/play/wwdc2015/406/) using 'XCUI POM Test Bundle' Templates. We can get pre-defined BDD steps by using XCFit Swift Framework from [CocoaPods](http://cocoadocs.org/docsets/XCFit), Carthage and Swift Package Manager.
|
43
|
+
|
44
|
+
* **Cucumberish BDD Framework and Cucucmber Style Xcode Templates**
|
43
45
|
|
44
|
-
XCFit setup [
|
46
|
+
XCFit setup [Cucumber](https://cucumber.io) style BDD framework with "[Cucumberish](https://github.com/Ahmed-Ali/Cucumberish) UI Test Bundle' Templates.
|
45
47
|
* **Fitnesse Acceptance Tests for iOS using OCSlim Project**
|
46
48
|
|
47
49
|
XCFit allows us to setup [Fitnesse](http://fitnesse.org/) style decision table test framework with [OCSlimProject](https://github.com/paulstringer/OCSlimProject) using 'Acceptance Tests Bundle' templates.
|
48
50
|
|
49
51
|
|
50
|
-
###
|
52
|
+
### Where to get XCFit
|
51
53
|
|
52
|
-
|
54
|
+
##### XCFit Swift Framework
|
53
55
|
|
54
|
-
* **
|
56
|
+
* **CocoaPods** -- [XCFit-CocoaPods](http://cocoadocs.org/docsets/XCFit) : XCFit Swift Frameworks and BDD Style predefined steps for the iOS App.
|
57
|
+
* **Carthage** -- You can install XCFit Swift Framework with Carthage as well for iOS Projects
|
58
|
+
* **Swift Package Manager** -- Swift Package Manager doesn't support iOS projects yet but XCFit is compatible with Swift Package manager as well.
|
55
59
|
|
56
|
-
|
60
|
+
##### XCFit Templates
|
61
|
+
|
62
|
+
* **Homebrew** - We can tap 'shashikant86/homebrew-taps' and Install XCFit to download Xcode Templates
|
63
|
+
|
64
|
+
* **RubyGems** -- [xcfit-RubyGem](https://rubygems.org/gems/xcfit) to get automated Xcode Templates
|
57
65
|
|
58
|
-
* **Swift Package Manager** : 2.0.0 : XCUI Test Framework Helpers
|
59
66
|
|
60
67
|
|
61
68
|
# Tech & Software Requirements
|
@@ -64,16 +71,17 @@ XCFit uses a number of open source projects to work properly. You need to have f
|
|
64
71
|
|
65
72
|
**Hardware**
|
66
73
|
|
67
|
-
You must have Mac Operating System with OSX/MacOS
|
74
|
+
You must have Mac Operating System with OSX/MacOS Sierra.
|
68
75
|
|
69
76
|
**Software**
|
70
77
|
|
71
|
-
|
72
|
-
|
73
|
-
* **[Xcode8](https://developer.apple.com/xcode/)**
|
78
|
+
|
79
|
+
* **[Xcode 8.3](https://developer.apple.com/xcode/)**
|
74
80
|
- Ideally Xcode 8 but works on Xcode 7 as well.
|
75
|
-
* **[
|
76
|
-
-
|
81
|
+
* **[Swift 3.1](https://swift.org/download/)**
|
82
|
+
- Use Swift 3.1-dev snapshot and toolchain.
|
83
|
+
* **[Ruby](https://www.ruby-lang.org/en/)**
|
84
|
+
- Use [RVM](https://rvm.io/) for GEM management. Ideally Ruby > 2.X. You can use system Ruby with sudo
|
77
85
|
* **[Curl on Mac](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/curl.1.html)**
|
78
86
|
- Might be pre-installed but worth double checking.
|
79
87
|
* **[Homebrew](http://brew.sh)**
|
@@ -88,10 +96,22 @@ You must have Mac Operating System with OSX/MacOS version > 10.9
|
|
88
96
|
|
89
97
|
# Installation
|
90
98
|
|
91
|
-
XCFit
|
99
|
+
XCFit installtion has two steps.
|
100
|
+
|
101
|
+
* **Xcode Template Installtion**
|
92
102
|
|
93
|
-
|
103
|
+
This will install Xcode Templates with skeloton code to support BDD in iOS app. The templates are XCUI Page Object Templates, Cucumberish BDD Templated and OCSlim Fitnesse Templates. The templates can be installed with [xcfit-RubyGem](https://rubygems.org/gems/xcfit) or [Homebrew](http://brew.sh).
|
94
104
|
|
105
|
+
* **Framework Installtion**
|
106
|
+
|
107
|
+
XCFit Swift Framework provided pre-defined BDD Style steps with XCUI and supporting Frameworks like Cucumberish and OCSlim used to write BDD Steps. XCFit Swift Framework is available on [XCFit-CocoaPods](http://cocoadocs.org/docsets/XCFit), Carthage and Swift Package manager. Cucumberish](https://github.com/Ahmed-Ali/Cucumberish) and [OCSlimProject](https://github.com/paulstringer/OCSlimProject) are available on Cocoapods.
|
108
|
+
|
109
|
+
XCFit can be installed using [Homebrew](http://brew.sh) or using [RubyGems](https://rubygems.org/).
|
110
|
+
|
111
|
+
## Template Installtion
|
112
|
+
|
113
|
+
XCFit templates can be installed using Homebrew or Rubygem.
|
114
|
+
### Homebrew Installtion
|
95
115
|
Assuming you have already installed [Homebrew](http://brew.sh). Let's tap the formula
|
96
116
|
|
97
117
|
brew tap shashikant86/homebrew-taps
|
@@ -100,40 +120,17 @@ Now, we can install XCFit brew package using
|
|
100
120
|
brew install xcfit
|
101
121
|
|
102
122
|
|
103
|
-
This
|
123
|
+
This will download XCFit templates.
|
104
124
|
|
105
|
-
|
125
|
+
### XCFit RubyGem Installtion
|
106
126
|
If you can't use HomeBrew for some reason then XCFit can be installed using [RubyGems](https://rubygems.org/). This will set our Xcode for BDD
|
107
127
|
|
108
128
|
$ gem install xcfit
|
109
129
|
|
110
|
-
You need to use with 'sudo' if you are using system (pre-installed) Ruby(2.0). XCFit gem will be used to set all the Xcode
|
130
|
+
You need to use with 'sudo' if you are using system (pre-installed) Ruby(2.0). XCFit gem will be used to set all the Xcode Templates for Xcode.
|
111
131
|
|
112
|
-
|
132
|
+
You can choose any of the above method. Rubygems method is prefered.
|
113
133
|
|
114
|
-
Once you installed XCFit with HomeBrew/Rubygem then you can execute 'xcfit' command from your terminal/iTerm etc etc. Example Output Looks like this :
|
115
|
-
|
116
|
-
```
|
117
|
-
$xcfit
|
118
|
-
setup_xcode_templates:
|
119
|
-
generate a Xcode 8 Templates for the Cucumberish and Fitnesse
|
120
|
-
setup_xcode7_templates:
|
121
|
-
generate a Xcode 7.x Templates. Please upgrade to Xcode 8
|
122
|
-
setup_gherkin:
|
123
|
-
generate Xcode Templates for the Gherkin Feature Files
|
124
|
-
get_cucumberish:
|
125
|
-
Downloads Cucumberish version
|
126
|
-
version:
|
127
|
-
prints the XCFit version
|
128
|
-
help:
|
129
|
-
prints more detailed help information.
|
130
|
-
```
|
131
|
-
|
132
|
-
|
133
|
-
## Install XCFit Cocoapod and Swift Package (Covered later)
|
134
|
-
|
135
|
-
Later, we need to install [XCFit](http://cocoadocs.org/docsets/XCFit) from CocoaPods to enable Cucumberish and Fitnesse test. We can also get XCFit from Swift Package Manager if we need to have additional helpers for the XCUI test framework.
|
136
|
-
Swift Packages only supports other Swift Packages.
|
137
134
|
|
138
135
|
---
|
139
136
|
|
@@ -156,6 +153,134 @@ You will see new option for iOS i.e 'XCFit'. Once Clicked on it. You will see Cu
|
|
156
153
|
|
157
154
|

|
158
155
|
|
156
|
+
## Framework Installtion
|
157
|
+
|
158
|
+
XCFit, Cucumberish or OCSlimProject Framework can be installed using Cocoapods. XCFit and Cuucmberish can be installed using Carthage as well but we will use Cocoapods as it's more automated than Carthage. We can create `Podfile` and add specific dependency for the target
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
target '$_YOUR__TARGET' do
|
162
|
+
pod 'XCFit'
|
163
|
+
end
|
164
|
+
```
|
165
|
+
Same way we can get 'Cucumberish' and 'OCSlim' for the specific target.
|
166
|
+
|
167
|
+
```sh
|
168
|
+
$ pod install
|
169
|
+
```
|
170
|
+
|
171
|
+
You need to close the existing Xcode session and Xcode Workspace .xcworkspace next time.
|
172
|
+
|
173
|
+
|
174
|
+
---
|
175
|
+
# XCFit Swift Framework : XCUI Page Object Pattern + Pre-Defined Steps
|
176
|
+
|
177
|
+
XCFit templates gives an option to use very polular [Page Object Pattern](http://martinfowler.com/bliki/PageObject.html) with Apple's Xcode UI Testing framework. You can install templates and start using the code straight way, no need to use framework unless you want to use pre-defined BDD style tests.
|
178
|
+
|
179
|
+
|
180
|
+
## Setup 'XCUI POM Test bundle' Target
|
181
|
+
|
182
|
+
- From Xcode, create a new app(Or use existing app) and selct File ---> New ----> Target
|
183
|
+
|
184
|
+
- Now Select 'XCFit' for iOS app and Click on 'XCUI POM Test Bundle'
|
185
|
+
|
186
|
+
- Once Clicked on the target e.g 'XCUI POM Test Bundle' Xcode will create UI testing target with properly structured Xcode Groups and required files. You can then make physical directories on Disk Or change the folder/group structure as per your need.
|
187
|
+
|
188
|
+
- You don't have to so any setting to run those demo XCUI tests. Just CMD+U and You are good to go !
|
189
|
+
|
190
|
+

|
191
|
+
|
192
|
+
### What's in the XCUI POM Template ?
|
193
|
+
|
194
|
+
* **YOUR_CUCUMBERISH_TARGETPageObjectTests.swift**
|
195
|
+
|
196
|
+
This file is at the base of the target. It's exactly same file that Apple's XCUI Test generate at first. You may use it for recording the tests or simply delete it if not needed.
|
197
|
+
|
198
|
+
* **Screens**
|
199
|
+
|
200
|
+
This is groups where we can abstract logic of every screen in the app. Example file are 'HomeScreen.swift' and 'BaseScreen.swift' This assumes that your apps is made up of multiple screens. You can write individual screen class which extend BaseScreen. All the functionality related to screen can be included in this class.
|
201
|
+
|
202
|
+
|
203
|
+
* **Tests**
|
204
|
+
|
205
|
+
This group has all the test for our app. Currently demo template has two tests 'HomeScreenTest.swift' and 'ProtocolOrientedTest.swift'. This examples shows how XCUI test can be implemented in the Object Orinted way and Protocol oriented way.
|
206
|
+
|
207
|
+
* **TestBase**
|
208
|
+
|
209
|
+
Testbase is group where we can abstract all setup, teardown and common stuff in the base class. Every Screen then use this class as base. You can add more stuff as needed e.g Fixtures, Launch Arguments
|
210
|
+
|
211
|
+
## Getting XCFit Framework for pre-defined BDD Style steps
|
212
|
+
|
213
|
+
### Cocoapods
|
214
|
+
You can get XCFit Framework eaily. Create `Podfile` and add specific dependency for the target
|
215
|
+
|
216
|
+
```ruby
|
217
|
+
target '$_YOUR__TARGET' do
|
218
|
+
pod 'XCFit'
|
219
|
+
end
|
220
|
+
```
|
221
|
+
Same way we can get 'Cucumberish' and 'OCSlim' for the specific target.
|
222
|
+
|
223
|
+
```sh
|
224
|
+
$ pod install
|
225
|
+
```
|
226
|
+
Close existing Xcode Session and Open `.xcworkspace/`. Now in the 'testBase' class just `import XCFit` and extend the class to `XCFit` class. The predefined steps are ready to use.
|
227
|
+
|
228
|
+

|
229
|
+
|
230
|
+
### Carthage
|
231
|
+
|
232
|
+
If you are using Carthage then it's easy to install XCFit. Add following to `Cartfile`
|
233
|
+
|
234
|
+
github "Shashikant86/XCFit"
|
235
|
+
|
236
|
+
Now fetch dependency and build XCFit using.
|
237
|
+
|
238
|
+
$ carthage update --platform iOS
|
239
|
+
This will create 'Carthage' directory with built framework. We need to manually drag and drop this to our XCUIPoMTest' target build settings. On your application targets’ “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop each framework you want to use from the Carthage/Build folder on disk. On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script in which you specify your shell (ex: bin/sh), add the following contents to the script area below the shell:
|
240
|
+
|
241
|
+
/usr/local/bin/carthage copy-frameworks
|
242
|
+
and add the paths to the frameworks you want to use under “Input Files”, e.g.:
|
243
|
+
|
244
|
+
$(SRCROOT)/Carthage/Build/iOS/XCFit.framework
|
245
|
+
|
246
|
+
Here is Carthage looks like
|
247
|
+

|
248
|
+
|
249
|
+
You can choose any of the above method but Cocoapods is easy and less manual.
|
250
|
+
|
251
|
+
### Import XCFit & Use Predefined Steps
|
252
|
+
|
253
|
+
There are some predefined XCFit steps we can use by importing `XCFit` and extending out test base class to `XCFit`. Your test will read something like this:
|
254
|
+
|
255
|
+
```
|
256
|
+
import XCTest
|
257
|
+
import XCFit
|
258
|
+
|
259
|
+
class XCFitTests: XCFit {
|
260
|
+
override func setUp() {
|
261
|
+
super.setUp()
|
262
|
+
continueAfterFailure = false
|
263
|
+
XCUIApplication().launch()
|
264
|
+
}
|
265
|
+
override func tearDown() {
|
266
|
+
super.tearDown()
|
267
|
+
}
|
268
|
+
|
269
|
+
func testCheckAlertPresent() {
|
270
|
+
givenILaunchedApplication()
|
271
|
+
whenITap(on: HomeScreen().homeButtuon)
|
272
|
+
thenIShouldSeeAnAlert()
|
273
|
+
}
|
274
|
+
}
|
275
|
+
|
276
|
+
|
277
|
+
```
|
278
|
+
|
279
|
+
|
280
|
+
You will get access to lots of predefined BDD style human redable steps. It's not mandatory to use those steps unless you wish.
|
281
|
+

|
282
|
+
|
283
|
+
|
159
284
|
---
|
160
285
|
|
161
286
|
# Setting Cucumberish BDD Scenarios in Xcode
|
@@ -169,8 +294,6 @@ You will see new option for iOS i.e 'XCFit'. Once Clicked on it. You will see Cu
|
|
169
294
|
- Once Clicked on the target e.g 'Cucumberish UI Test Bundle' Xcode will create UI testing target with all the required files with Bridging header for Cucumberish UI Testing. It create Page Object Pattern with all required files with screens, steps definitions and Cucumberish initialiser swift file.
|
170
295
|
|
171
296
|
|
172
|
-

|
173
|
-
|
174
297
|
### What's in the Cucumberish Template ?
|
175
298
|
|
176
299
|
* **YOUR_CUCUMBERISH_TARGET.swift**
|
@@ -215,12 +338,6 @@ Given the app is running
|
|
215
338
|
|
216
339
|
- Select only '**Create folder references**' Option. ** Do Not Select 'Create groups' Or 'Copy items if needed**'
|
217
340
|
|
218
|
-
Here is how to do it.
|
219
|
-

|
220
|
-
|
221
|
-
* **Cucumberish Header Files**
|
222
|
-
|
223
|
-
We still don't have content of [Cucumberish](https://github.com/Ahmed-Ali/Cucumberish/tree/master/Cucumberish) to be included in our project.
|
224
341
|
|
225
342
|
### Getting Cucumberish CocoaPod into our Target
|
226
343
|
|
@@ -232,35 +349,22 @@ Create a 'Podfile' if you don't have already. In your Podfile, add following Pod
|
|
232
349
|
|
233
350
|
```ruby
|
234
351
|
target '$_YOUR_CUCUMBERISH_TARGET' do
|
235
|
-
pod '
|
352
|
+
pod 'Cucumberish'
|
236
353
|
end
|
237
354
|
```
|
238
355
|
|
239
356
|
|
240
|
-
|
241
357
|
```sh
|
242
358
|
$ pod install
|
243
359
|
```
|
244
360
|
|
245
|
-
You can do that easily.
|
246
|
-

|
247
|
-
|
248
|
-
Now close the existing Xcode session and Xcode Workspace next time.
|
249
|
-
|
250
|
-
|
251
|
-
- **Manual Installtion (not recommended use CocoaPods instaed )**
|
252
|
-
|
253
|
-
We can manually copy content of [Cucumberish](https://github.com/Ahmed-Ali/Cucumberish/tree/master/Cucumberish) directory and drag to target as with option "**Create groups" and "Copy items if needed**".
|
254
|
-
|
255
|
-
Here is How to setup everything in a minute
|
256
|
-
|
257
|
-

|
258
361
|
|
362
|
+
Now close the existing Xcode session and Xcode Workspace `.xcworkspace` next time.
|
259
363
|
|
260
364
|
We now have everything we needed to run demo Cucumber demo test. Update Scheme if don't want to run unit test or other type of tests.
|
261
365
|
and press 'CMD+U'
|
262
366
|
|
263
|
-

|
264
368
|
|
265
369
|
Congratulations !! You have just ran your first Cucumber BDD Scenario in the Xcode. Now add your own :)
|
266
370
|
|
@@ -270,78 +374,6 @@ XCFit adds 'Cucumberish' target to existing Scheme. You can remove that target a
|
|
270
374
|
|
271
375
|
---
|
272
376
|
|
273
|
-
# XCUI Page Object Pattern and Pre-Defined Steps
|
274
|
-
|
275
|
-
Now, we have seen that it's failrly easy to setup BDD Style tests with Cucumberish but some people don't want that overhead of adding extra layer of Gherkin. XCFit gives an option to use very polular [Page Object Pattern](http://martinfowler.com/bliki/PageObject.html) with Apple's Xcode UI Testing framework.
|
276
|
-
|
277
|
-
## Setup 'XCUI POM Test bundle' Target
|
278
|
-
|
279
|
-
- From Xcode, create a new app(Or use existing app) and selct File ---> New ----> Target
|
280
|
-
|
281
|
-
- Now Select 'XCFit' for iOS app and Click on 'XCUI POM Test Bundle'
|
282
|
-
|
283
|
-
- Once Clicked on the target e.g 'XCUI POM Test Bundle' Xcode will create UI testing target with properly structured Xcode Groups and required files. You can then make physical directories on Disk Or change the folder/group structure as per your need.
|
284
|
-
|
285
|
-
- You don't have to so any setting to run those demo XCUI tests. Just CMD+U and You are good to go !
|
286
|
-
|
287
|
-
|
288
|
-

|
289
|
-
|
290
|
-
### What's in the XCUI POM Template ?
|
291
|
-
|
292
|
-
* **YOUR_CUCUMBERISH_TARGETPageObjectTests.swift**
|
293
|
-
|
294
|
-
This file is at the base of the target. It's exactly same file that Apple's XCUI Test generate at first. You may use it for recording the tests or simply delete it if not needed.
|
295
|
-
|
296
|
-
* **Screens**
|
297
|
-
|
298
|
-
This is groups where we can abstract logic of every screen in the app. Example file are 'HomeScreen.swift' and 'BaseScreen.swift' This assumes that your apps is made up of multiple screens. You can write individual screen class which extend BaseScreen. All the functionality related to screen can be included in this class.
|
299
|
-
|
300
|
-
* **Sections**
|
301
|
-
|
302
|
-
This group has 'HomeElements.swift' class which stores all the locators of HomeScreen in enums. Sections are defined to store locators of the screen in the form of enums. Here are some samples we can store Images, Buttons and Static Texts of the HomeScreens. We can access those enums from anywhere from the Test methods or page objects.
|
303
|
-
|
304
|
-
* **Protocols**
|
305
|
-
|
306
|
-
Swift is protocol oriented language so feel to start with Protocol per screen. This group has 'HomeProtocol.swift' file where there is way to implement protocol oriented testing. Here is example of sample protocol for the homescreen. We can implement this protocol in the XCTest method as needed or we can write some extensions to support Testing.
|
307
|
-
|
308
|
-
* **Tests**
|
309
|
-
|
310
|
-
This group has all the test for our app. Currently demo template has two tests 'HomeScreenTest.swift' and 'ProtocolOrientedTest.swift'. This examples shows how XCUI test can be implemented in the Object Orinted way and Protocol oriented way.
|
311
|
-
|
312
|
-
* **TestBase**
|
313
|
-
|
314
|
-
Testbase is group where we can abstract all setup, teardown and common stuff in the base class. Every Screen then use this class as base. You can add more stuff as needed e.g Fixtures, Launch Arguments
|
315
|
-
|
316
|
-
## Using Predefined XCFit BDD Style Steps
|
317
|
-
|
318
|
-
There are some predefined XCFit steps we can use by importing `XCFit` and extending out test class to `XCFit`.
|
319
|
-
|
320
|
-
import XCTest
|
321
|
-
import XCFit
|
322
|
-
|
323
|
-
class XCFitTests: XCFit {
|
324
|
-
override func setUp() {
|
325
|
-
super.setUp()
|
326
|
-
continueAfterFailure = false
|
327
|
-
XCUIApplication().launch()
|
328
|
-
}
|
329
|
-
override func tearDown() {
|
330
|
-
super.tearDown()
|
331
|
-
}
|
332
|
-
|
333
|
-
func testExample() {
|
334
|
-
givenILaunchedApplication()
|
335
|
-
whenITap(on: HomeScreen().crappyButtuon)
|
336
|
-
thenIShouldSeeAnAlert()
|
337
|
-
}
|
338
|
-
}
|
339
|
-
`
|
340
|
-
|
341
|
-
You will get access to lots of predefined BDD style human redable steps. It's not mandatory to use those ste it
|
342
|
-
|
343
|
-
|
344
|
-
---
|
345
377
|
|
346
378
|
# Fitnesse for iOS: Acceptance/Contract Tests
|
347
379
|
|
@@ -431,62 +463,9 @@ Now if you select “AcceptanceUnitTarget” and press CMD+U.
|
|
431
463
|
Now we can see that FitNesse tests are running as shown above. We can add this to main scheme to make sure we are running it after the unit tests to follow proper development workflow. We can build and run it as our normal unit tests.
|
432
464
|
|
433
465
|
|
434
|
-
# Continuous Integration
|
435
|
-
|
436
|
-
Now that , we have seen how to run Cucumberish, XCUIPOM, FitNesse acceptance tests from Xcode but it’s a good idea to run it with Fastlane. We can also take control of version of Cocoapods and Fastlane by using Bundler. Let’s create a Gemfile at the root of the project with the following gem
|
437
|
-
|
438
|
-
```ruby
|
439
|
-
source "https://rubygems.org"
|
440
|
-
gem 'cocoapods'
|
441
|
-
gem 'fastlane' plugins_path = File.join(File.dirname(__FILE__), '.', 'Pluginfile') eval(File.read(plugins_path), binding) if File.exist?(plugins_path
|
442
|
-
```
|
443
|
-
|
444
|
-
Let’s also create directory “fastlane” and make “Fastfile” with following content
|
445
|
-
|
446
|
-
```ruby
|
447
|
-
|
448
|
-
fastlane_version "1.104.0"
|
449
|
-
default_platform :ios
|
450
|
-
platform :ios do
|
451
|
-
before_all do
|
452
|
-
system "rm -rf ../test_reports/"
|
453
|
-
system "bundle install"
|
454
|
-
system "pod install"
|
455
|
-
system "bundle exec fastlane add_plugin trainer"
|
456
|
-
end
|
457
|
-
desc "Runs all the XCUI POM, Cucumberish tests"
|
458
|
-
lane :xcfit_ui_test do
|
459
|
-
scan(
|
460
|
-
scheme: "XCFit2Demo",
|
461
|
-
destination: 'platform=iOS Simulator,name=iPhone 7 Plus,OS=10.0',
|
462
|
-
output_directory: "test_reports/",
|
463
|
-
output_types: "html",
|
464
|
-
fail_build: false
|
465
|
-
)
|
466
|
-
end
|
467
|
-
|
468
|
-
desc "Runs Fitnesse Tests"
|
469
|
-
lane :fitnesse do
|
470
|
-
scan(
|
471
|
-
scheme: "AcceptanceUnitTests",
|
472
|
-
destination: 'platform=iOS Simulator,name=iPhone 7 Plus,OS=10.0',
|
473
|
-
output_directory: "test_reports/",
|
474
|
-
output_types: "html",
|
475
|
-
fail_build: false
|
476
|
-
)
|
477
|
-
end
|
478
|
-
end
|
479
|
-
```
|
480
|
-
|
481
|
-
After running “bundle install” we should be able to run those test from command line like this :
|
482
|
-
|
483
|
-
$ bundle exec fastlane xcfit_ui_test
|
484
|
-
|
485
|
-
|
486
|
-

|
487
|
-
|
488
|
-
Once that done. We can have clear HTML reports genearted
|
466
|
+
# Continuous Integration with Xcode Server
|
489
467
|
|
468
|
+
Coming Soon
|
490
469
|
|
491
470
|
# XCFit: Swift Package Manager
|
492
471
|
|
@@ -499,7 +478,7 @@ import PackageDescription
|
|
499
478
|
let package = Package(
|
500
479
|
name: "XCFit",
|
501
480
|
dependencies: [
|
502
|
-
.Package(url: "https://github.com/Shashikant86/XCFit.git", majorVersion:
|
481
|
+
.Package(url: "https://github.com/Shashikant86/XCFit.git", majorVersion: 4.0.0),
|
503
482
|
]
|
504
483
|
)
|
505
484
|
```
|