xcfit 2.0.9 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/Docs/README_XCFit2.md +572 -0
  3. data/Gemfile.lock +2 -2
  4. data/README.md +182 -203
  5. data/homebrew/xcfit +25 -6
  6. data/lib/XCFit/main.rb +13 -0
  7. data/lib/XCFit/version.rb +1 -1
  8. metadata +3 -21
  9. data/XCFit_Templates/XCFit/Base Acceptance Testing Bundle.xctemplate/TemplateIcon.icns +0 -0
  10. data/XCFit_Templates/XCFit/Base Acceptance Testing Bundle.xctemplate/TemplateInfo.plist +0 -134
  11. data/XCFit_Templates/XCFit/Base Acceptance Testing Bundle.xctemplate/___PACKAGENAMEASIDENTIFIER___.m +0 -17
  12. data/XCFit_Templates/XCFit/Base Acceptance Testing Bundle.xctemplate/___PACKAGENAMEASIDENTIFIER___.swift +0 -13
  13. data/XCFit_Templates/XCFit/Base Acceptance Testing Bundle.xctemplate/___POD_NAME___.m +0 -25
  14. data/XCFit_Templates/XCFit/Base Acceptance Tests.xctemplate/AcceptanceTests-Bridging-Header.h +0 -1
  15. data/XCFit_Templates/XCFit/Base Acceptance Tests.xctemplate/FixtureExample.swift +0 -35
  16. data/XCFit_Templates/XCFit/Base Acceptance Tests.xctemplate/SlimTables.h +0 -28
  17. data/XCFit_Templates/XCFit/Base Acceptance Tests.xctemplate/TemplateInfo.plist +0 -155
  18. data/XCFit_Templates/XCFit/Base Acceptance Tests.xctemplate/___PACKAGENAMEASIDENTIFIER___-Bridging-Header.h +0 -12
  19. data/XCFit_Templates/XCFit/Base Acceptance Tests.xctemplate/___PACKAGENAMEASIDENTIFIER___.m +0 -33
  20. data/XCFit_Templates/XCFit/iOS Acceptance Testing Bundle.xctemplate/TemplateIcon-old.icns +0 -0
  21. data/XCFit_Templates/XCFit/iOS Acceptance Testing Bundle.xctemplate/TemplateIcon.png +0 -0
  22. data/XCFit_Templates/XCFit/iOS Acceptance Testing Bundle.xctemplate/TemplateIcon@2x.png +0 -0
  23. data/XCFit_Templates/XCFit/iOS Acceptance Testing Bundle.xctemplate/TemplateInfo.plist +0 -40
  24. data/XCFit_Templates/XCFit/iOS Acceptance Tests.xctemplate/TemplateIcon-old.icns +0 -0
  25. data/XCFit_Templates/XCFit/iOS Acceptance Tests.xctemplate/TemplateIcon.png +0 -0
  26. data/XCFit_Templates/XCFit/iOS Acceptance Tests.xctemplate/TemplateIcon@2x.png +0 -0
  27. data/XCFit_Templates/XCFit/iOS Acceptance Tests.xctemplate/TemplateInfo.plist +0 -59
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aaade4ec14f93632f97a81e063d4eafc719efd76
4
- data.tar.gz: a864cbb5ad145f97ccd0b8ad5d8fd0da763f9d87
3
+ metadata.gz: 99d5de4758e70d5a315f6d9f65a071858df867b5
4
+ data.tar.gz: 8c689e4f39965fdd41560322f5ab048aa67f4fc8
5
5
  SHA512:
6
- metadata.gz: cadf871f7bf70c6f7f49d9fb214d754607c32389935d74050eb484f335db65b750ae7bdbefcb4dd5de07d7e3da68622962875988a15d4206687ccadb231d1fa9
7
- data.tar.gz: c9d00dbaa039d730a1af49785473eb8fda05ddf8d192fd70e63c9d44e578fd8a4a56ee4ab6a2b6034adbb5ca6348868a995b80f17e1cefa79d5a00b7265170cf
6
+ metadata.gz: 234fdc96936a9781b9fbba756fa3efe4511348638c4a289b7a7c864ef15e1a92ec7345dc85a5f51dddb1d7d703097c289e9e580ec22265d95145d4a0e3787571
7
+ data.tar.gz: 364eb6687e2d85252fef93a71bc4ebdad3508ff64717f0f7b7cbd01e2e0a85ab94e01f177c0de9d4be48c89dc38b9865edbc3a056ff514e8e54296284b573b0e
@@ -0,0 +1,572 @@
1
+ [![CI Status](http://img.shields.io/travis/Shashikant86/XCFit.svg?style=flat)](https://travis-ci.org/Shashikant86/XCFit)
2
+ [![Version](https://img.shields.io/cocoapods/v/XCFit.svg?style=flat)](http://cocoapods.org/pods/XCFit)
3
+ [![License](https://img.shields.io/cocoapods/l/XCFit.svg?style=flat)](http://cocoapods.org/pods/XCFit)
4
+ [![Platform](https://img.shields.io/cocoapods/p/XCFit.svg?style=flat)](http://cocoapods.org/pods/XCFit)
5
+
6
+ # XCFit : Full Stack BDD in Xcode
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 and macOS apps. XCFit allows us to write API 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 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) and Swift Package Manager.**
9
+
10
+ ### XCFit
11
+
12
+
13
+ * [XCFit : Full Stack BDD in Xcode](#xcfit--full-stack-bdd-in-xcode)
14
+ * [XCFit Features](#xcfit-features)
15
+ * [Tech & Software Requirements](#tech--software-requirements)
16
+ * [Installation](#installation)
17
+ * [Setup Xcode Templates](#setup-xcode-templates)
18
+ * [Setting Cucumberish BDD Scenarios in Xcode](#setting-cucumberish-bdd-scenarios-in-xcode)
19
+ * [XCUI Page Object Pattern](#xcui-page-object-pattern)
20
+ * [Fitnesse for iOS: Acceptance/Contract Tests](#fitnesse-for-ios-acceptancecontract-tests)
21
+ * [Continuous Integration Fastlane](#continuous-integration--fastlane)
22
+ * [XCFit: Swift Package Manager](#xcfit-swift-package-manager)
23
+ * [Quick Demo with Example App](#quick-demo-with-example-app)
24
+ * [Acknowledgements](#acknowledgements)
25
+ * [Author](#author)
26
+ * [TODO](#todo)
27
+ * [LICENSE](#license)
28
+ * [Contributing](#contributing)
29
+
30
+ # XCFit Features
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.
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. All happens in one command
35
+ - XCFit will setup test frameworks within a minute and works for Xcode 8 and Xcode 7.
36
+
37
+
38
+ ### XCFIT allows follwing frameworks
39
+ * **Cucumberish BDD Framework**
40
+
41
+ XCFit setup [Cucumber](https://cucumber.io) style BDD framework with "[Cucumberish](https://github.com/Ahmed-Ali/Cucumberish) UI Test Bundle' Templates
42
+ * **Page Object Pattern for XCUI Test framework from Apple**
43
+
44
+ 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
45
+ * **Fitnesse Acceptance Tests for iOS using OCSlim Project**
46
+
47
+ 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
+
49
+
50
+ ### XCFit Available on
51
+
52
+ * **CocoaPods** -- [XCFit-CocoaPods](http://cocoadocs.org/docsets/XCFit) : BDD Style scenarios for iOS App
53
+
54
+ * **Homebrew** - Just do `brew tap shashikant86/homebrew-taps` and `brew install xcfit`
55
+
56
+ * **RubyGems** -- [xcfit-RubyGem](https://rubygems.org/gems/xcfit) : Automated Xcode Templates
57
+
58
+ * **Swift Package Manager** : 2.0.0 : XCUI Test Framework Helpers
59
+
60
+
61
+ # Tech & Software Requirements
62
+
63
+ XCFit uses a number of open source projects to work properly. You need to have following
64
+
65
+ **Hardware**
66
+
67
+ You must have Mac Operating System with OSX/MacOS version > 10.9
68
+
69
+ **Software**
70
+
71
+ * **[Ruby](https://www.ruby-lang.org/en/)**
72
+ - Use [RVM](https://rvm.io/) for GEM management. Ideally Ruby > 2.X. You can use system Ruby with sudo
73
+ * **[Xcode8](https://developer.apple.com/xcode/)**
74
+ - Ideally Xcode 8 but works on Xcode 7 as well.
75
+ * **[RubyGems](https://rubygems.org/)**
76
+ - RubyGem with [Cocoapods](https://cocoapods.org/) installed
77
+ * **[Curl on Mac](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/curl.1.html)**
78
+ - Might be pre-installed but worth double checking.
79
+ * **[Homebrew](http://brew.sh)**
80
+ * **[iOS-Sim](https://www.npmjs.com/package/ios-sim)**
81
+ - Node Package required to launch iOS app for Fitnesse Acceptance tests.
82
+ * [**Java**](https://www.java.com/en/)
83
+ - Java should be installed on Mac, it is required for Fitnesse Acceptance Test
84
+ * **Ruby Packages(optional)**
85
+ - Xcpretty, Fastlane(Optional), Rake, Bundler etc
86
+
87
+ ---
88
+
89
+ # Installation
90
+
91
+ XCFit can be installed using [Homebrew](http://brew.sh) or using [RubyGems](https://rubygems.org/) but it's strongly recommended to install it using Homebrew.
92
+
93
+ ## Install with HomeBrew
94
+
95
+ Assuming you have already installed [Homebrew](http://brew.sh). Let's tap the formula
96
+
97
+ brew tap shashikant86/homebrew-taps
98
+ Now, we can install XCFit brew package using
99
+
100
+ brew install xcfit
101
+
102
+
103
+ This is recommended method to install `XCFit` over the Rubygem mentioned below.
104
+
105
+ ## Install XCFit Gem
106
+ 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
+
108
+ $ gem install xcfit
109
+
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 Templated for Xcode 8 as well Xcode 7
111
+
112
+ # XCFit Commands
113
+
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
+
138
+ ---
139
+
140
+ # Setup Xcode Templates
141
+
142
+ In existing app or brand new app, we have to enable the Xcode templates for targets to speed up the things.
143
+ ##### Xcode 8
144
+ To setup Templates for Xcode 8.
145
+
146
+
147
+ ```sh
148
+ $ xcfit set_xcode_templates
149
+
150
+ ```
151
+
152
+
153
+ - This will add couple of templates to your Xcode for iOS and macOS apps. In your app if you go to 'File--->New--->Target'
154
+
155
+ You will see new option for iOS i.e 'XCFit'. Once Clicked on it. You will see Cucumberish UI and Fitnesse Acceptance Tests. XCUI POM, Fitnesse Acceptance Unit Test bundles. As shown
156
+
157
+ ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/Xcode8-Templates.png)
158
+
159
+ ---
160
+
161
+ # Setting Cucumberish BDD Scenarios in Xcode
162
+
163
+ ## Setup 'iOS UI Cucumberish Test Bundle' Target
164
+
165
+ - From Xcode, create a new app(Or use existing app) and selct File ---> New ----> Target
166
+
167
+ - Now Select 'XCFit' for iOS app and Click on 'Cucumberish UI Test Bundle'
168
+
169
+ - 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
+
171
+
172
+ ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/XCFit_CucumberishTemplates.gif)
173
+
174
+ ### What's in the Cucumberish Template ?
175
+
176
+ * **YOUR_CUCUMBERISH_TARGET.swift**
177
+
178
+ This file is at the base of the target. This initiate Cucumberish for project. We need to register all step definitions in this file.
179
+ * **Screens**
180
+
181
+ This is groups where we can abstract logic of every screen in the app. Example file are 'HomeScreen.swift' and 'BaseScreen.swift'
182
+
183
+ * **Step_Definitions**
184
+
185
+ This groups has all the step definitions related to screen. Example file 'HomeScreenSteps.swift'. Once implemented we need to register it in the initialiser file mentioned above.
186
+
187
+ * **Common**
188
+
189
+ This group has common code like extensions and common steps. The example file 'CommonStepDefinitions.swift' has some steps that can be used in the feature file. It also has 'Hooks.swift' to ad cucumber hooks.
190
+
191
+ * **Supporting Files**
192
+
193
+ This groups all the Objective-C headers and Bridging headers needed to get Cucumberish working with Swift.
194
+
195
+ ### What's not in the Cucumberish Template
196
+
197
+ * **Features Directory**
198
+
199
+ We don't have 'Features' directory in the template because it needs to have directory on the disk and should be added to Xcode as 'Folder Reference' not Group.
200
+
201
+ - Create a Direcory called "Feature"
202
+
203
+ - Now Add sample Gherkin Feature File to 'Features' directory either by File->New->Gherkin Or Just add it using your favourite text editor e.g demo.feature with content
204
+
205
+ ```
206
+ Feature: Demo App Feature
207
+
208
+ Scenario: Demo Scenario
209
+
210
+ Given the app is running
211
+
212
+ ```
213
+
214
+ - Now Drag and Drop 'Features' directory to Xcode Cucumberish target
215
+
216
+ - Select only '**Create folder references**' Option. ** Do Not Select 'Create groups' Or 'Copy items if needed**'
217
+
218
+ Here is how to do it.
219
+ ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/AddFeaturesDirectory.gif)
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
+
225
+ ### Getting Cucumberish CocoaPod into our Target
226
+
227
+ In order to get [Cucumberish](https://github.com/Ahmed-Ali/Cucumberish/tree/master/Cucumberish) source content. There are few ways we can do that
228
+
229
+ - **Cocoapods**
230
+
231
+ Create a 'Podfile' if you don't have already. In your Podfile, add following Pod entry and update/install pod
232
+
233
+ ```ruby
234
+ target '$_YOUR_CUCUMBERISH_TARGET' do
235
+ pod 'XCFit'
236
+ end
237
+ ```
238
+
239
+
240
+
241
+ ```sh
242
+ $ pod install
243
+ ```
244
+
245
+ You can do that easily.
246
+ ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/AddPod.gif)
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
+ ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/XCFitStartUp.gif)
258
+
259
+
260
+ 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
+ and press 'CMD+U'
262
+
263
+ ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/CucumberTest.gif)
264
+
265
+ Congratulations !! You have just ran your first Cucumber BDD Scenario in the Xcode. Now add your own :)
266
+
267
+ #### Create Separate Scheme if needed
268
+
269
+ XCFit adds 'Cucumberish' target to existing Scheme. You can remove that target and run separate scheme to keep it independent from Unit tests. Make sure you make the new scheme executable for Running.
270
+
271
+ ---
272
+
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
+ ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/XCUIPOM.gif)
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
+
346
+ # Fitnesse for iOS: Acceptance/Contract Tests
347
+
348
+ [Fitnesse](http://fitnesse.org/) is fully integrated standalone wiki and acceptance testing framework for BDD Style testing. As of now we have seen Cucumber and Page Object pattern test frameworks. If you really wanted to get more information about Fitnnese for iOS, please follow documentation on [OCSlim](http://paulstringer.github.io/OCSlimProject/) project. XCFit adopted the framework as dependeny to make it full stack BDD. We will cover basic setup as part of this document.
349
+
350
+ ## Setup 'Acceptance Test' Target template
351
+
352
+ - From Xcode, create a new app(Or use existing app) and selct File ---> New ----> Target
353
+
354
+ - Now Select 'XCFit' for iOS app and Click on 'iOS Acceptance Tests '
355
+
356
+ - Once Clicked on the target e.g 'OS Acceptance Tests' Xcode will create new target with all required files and groups for Acceptance testing
357
+
358
+ - Select 'Acceptance Test' Scheme from Xcode and try to build
359
+
360
+ - The build will fail as we need fix some **Swift3** related issue as well as we need to add **XCFit/OCSlimProject** Pod to the to the podfile.
361
+
362
+ ** Watch it so far**
363
+
364
+ ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/AcceptanceTestsTarget.gif)
365
+
366
+ 1. To Fix Swift Issue : Just Click on ‘Edit-> Convert-> To Current Swift Syntax
367
+ 2. To Fix Pod issue : Add 'XCFit' for AcceptanceTests target
368
+
369
+ ```ruby
370
+ target 'AcceptanceTests' do
371
+ pod 'OCSlimProject'
372
+ end
373
+ ```
374
+
375
+
376
+
377
+ ```sh
378
+ $ pod install
379
+ ```
380
+
381
+ Now, You should be able to build 'Acceptance Tests" target.
382
+
383
+ You should also note that, the script 'Launch Fitnesse' has been created in the base of the project. Launch the fitness by exucuting that script from command line
384
+
385
+ $ sh Launch Fitnesse
386
+
387
+ The browser will popup with example test. You should be able to excute that suite and see then running and passing
388
+
389
+ ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/AcceptanceTestsTargetPod.gif)
390
+
391
+ If you get any errors at this stage, please confirm that you have Java as well as ios-sim node package installed.
392
+
393
+ So, Congratulations again.. You have just executed Fitnesse test fro browser which is talking to your app.
394
+
395
+
396
+ ## Setting up Fitnesse Acceptance Target with XCTest
397
+
398
+ You can also setup Fitnesse Acceptance Tests but you need to use Cocoapods for this target.
399
+
400
+ You can find detailed blog post on [Dzone](https://dzone.com/articles/integrate-fitnesse-with-xctest-using-xcode8)
401
+
402
+ #### Add Acceptance and Acceptance Unit Test Target to Project
403
+
404
+ We have all the predefined targets for FitNesse. Just add “Acceptance Tests” target from the template and “AcceptanceUnitTests” target from the bundle. You will need “FitNesse Suite page name” to create this target but just put “OCSlimProjectExamplePage” there for now . Add your ‘AcceptanceTests’ target as a ‘Target Dependancy’ of this new target in Build Phases. This ensures that it the latest code has been built prior to the tests being run.
405
+
406
+
407
+ #### Add Pod Dependencies
408
+ We need to create a “Podfile” at the root of the project with the following content.
409
+
410
+ ```ruby
411
+ target 'AcceptanceUnitTests' do
412
+ pod 'OCSlimProjectTestBundleSupport'
413
+ end
414
+ ```
415
+
416
+ Now, we can run ‘pod install’ at this stage and close the current Xcode session and open project workspace.
417
+
418
+ #### Build Acceptance Tests Target
419
+ At this stage, we should be able to build the “Acceptance Tests” target. If you are using Xcode8, you might see some warning related to the Swift3 Syntax. Just Click on ‘Edit-> Convert-> To Current Swift Syntax
420
+
421
+ Now you should be able to build an “Acceptance Tests” target. Once, build is successful, you should see “LaunchFitnesse” script is generated in the root of the project. We can launch and execute the fitness test as shown below.
422
+
423
+
424
+ #### Test AcceptanceUnitTests Target
425
+
426
+ Now if you select “AcceptanceUnitTarget” and press CMD+U.
427
+
428
+ ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/FitnesseXCTest.gif)
429
+
430
+
431
+ 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
+
433
+
434
+ # Continuous Integration + Fastlane
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
+ ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/FastlaneXCFit.gif)
487
+
488
+ Once that done. We can have clear HTML reports genearted
489
+
490
+
491
+ # XCFit: Swift Package Manager
492
+
493
+ XCFit will be having full on support for XCUI Test helpers so that we can use Apple's XCUI Test Framework painless to use. There is [sample swift package](https://github.com/Shashikant86/XCFitDemoSwiftPackage) on Github to test XCFit
494
+ Full Documetation and API implementation still in progress. You can grab it like this
495
+
496
+ ```
497
+ import PackageDescription
498
+
499
+ let package = Package(
500
+ name: "XCFit",
501
+ dependencies: [
502
+ .Package(url: "https://github.com/Shashikant86/XCFit.git", majorVersion: 2),
503
+ ]
504
+ )
505
+ ```
506
+
507
+
508
+
509
+ # Quick Demo with Example App
510
+
511
+ You can clone the existing repo which has a demo app we can run Unit, Fitnesse and Cucumbertish Tests as XCTest
512
+ ```
513
+ $ git clone https://github.com/Shashikant86/XCFit
514
+ $ cd XCFit/XCFit2Demo
515
+ $ open XCFit2Demo.xcworkspace
516
+ ```
517
+ Run Unit, Fitnesse and Cucumberish test with Xcode. "cmd + U". We can execute it using Fastlane
518
+
519
+
520
+ ```
521
+ $ bundle install
522
+ $ bundle exec fastlane xcfit_ui_test
523
+ ```
524
+
525
+
526
+ # Acknowledgements
527
+
528
+ Big Thanks to
529
+ - [Cucumberish](https://github.com/Ahmed-Ali/Cucumberish) : Provide native [Gherkin](https://github.com/cucumber/cucumber/wiki/Gherkin) parser for iOS Apps to enable BDD in Xcode using Given When Then. Yay!
530
+ - [OCSlimProject](https://github.com/paulstringer/OCSlimProject) : Provide Xcode Templates to enable BDD with Decision Tables using Fitnesse
531
+
532
+
533
+ # Author
534
+
535
+ Shashikant86, shashikant.jagtap@icloud.com
536
+
537
+ # TODO
538
+
539
+ * Add More Step Definitions for Cucumberish Projects
540
+ * Improve Swift Package with additional XCUI test helpers
541
+ * Setting up XCFit on Apple's own CI Xcode Server
542
+
543
+ # LICENSE
544
+
545
+ Copyright © 2014 Shashikant Jagtap, http://shashikantjagtap.net
546
+
547
+ Permission is hereby granted, free of charge, to any person obtaining
548
+ a copy of this software and associated documentation files (the
549
+ "Software"), to deal in the Software without restriction, including
550
+ without limitation the rights to use, copy, modify, merge, publish,
551
+ distribute, sublicense, and/or sell copies of the Software, and to
552
+ permit persons to whom the Software is furnished to do so, subject to
553
+ the following conditions:
554
+
555
+ The above copyright notice and this permission notice shall be
556
+ included in all copies or substantial portions of the Software.
557
+
558
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
559
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
560
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
561
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
562
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
563
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
564
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
565
+
566
+ # Contributing
567
+
568
+ 1. Fork it ( https://github.com/Shashikant86/XCFit/fork )
569
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
570
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
571
+ 4. Push to the branch (`git push origin my-new-feature`)
572
+ 5. Create a new Pull Request