xcfit 3.1.5 → 3.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -1
  3. data/Pre-Defined_Steps/Cucumberish_Predefined_Steps.md +12 -0
  4. data/Pre-Defined_Steps/XCFit_Predefined_Steps.md +49 -0
  5. data/README.md +53 -31
  6. data/XCFit.podspec +1 -1
  7. data/XCFit4Demo/Cartfile +1 -0
  8. data/XCFit4Demo/Cartfile.resolved +2 -0
  9. data/XCFit4Demo/XCFit4Demo.xcodeproj/project.pbxproj +864 -0
  10. data/XCFit4Demo/XCFit4Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  11. data/XCFit4Demo/XCFit4Demo/AppDelegate.swift +46 -0
  12. data/XCFit4Demo/XCFit4Demo/Assets.xcassets/AppIcon.appiconset/Contents.json +38 -0
  13. data/XCFit4Demo/XCFit4Demo/Base.lproj/LaunchScreen.storyboard +27 -0
  14. data/XCFit4Demo/XCFit4Demo/Base.lproj/Main.storyboard +53 -0
  15. data/XCFit4Demo/XCFit4Demo/Info.plist +38 -0
  16. data/XCFit4Demo/XCFit4Demo/ViewController.swift +33 -0
  17. data/XCFit4Demo/XCFit4DemoCucumberTests/BaseScreen.swift +21 -0
  18. data/XCFit4Demo/XCFit4DemoCucumberTests/CommonStepDefinitions.swift +89 -0
  19. data/XCFit4Demo/XCFit4DemoCucumberTests/Extensions.swift +57 -0
  20. data/XCFit4Demo/XCFit4DemoCucumberTests/Features/demo.feature +8 -0
  21. data/XCFit4Demo/XCFit4DemoCucumberTests/HomeScreen.swift +24 -0
  22. data/XCFit4Demo/XCFit4DemoCucumberTests/HomeScreenSteps.swift +29 -0
  23. data/XCFit4Demo/XCFit4DemoCucumberTests/Hooks.swift +27 -0
  24. data/XCFit4Demo/XCFit4DemoCucumberTests/Info.plist +22 -0
  25. data/XCFit4Demo/XCFit4DemoCucumberTests/XCFit4DemoCucumberTests-Bridging-Header.h +17 -0
  26. data/XCFit4Demo/XCFit4DemoCucumberTests/XCFit4DemoCucumberTests.h +22 -0
  27. data/XCFit4Demo/XCFit4DemoCucumberTests/XCFit4DemoCucumberTests.m +27 -0
  28. data/XCFit4Demo/XCFit4DemoCucumberTests/XCFit4DemoCucumberTests.swift +39 -0
  29. data/XCFit4Demo/XCFit4DemoTests/Info.plist +22 -0
  30. data/XCFit4Demo/XCFit4DemoTests/XCFit4DemoTests.swift +36 -0
  31. data/XCFit4Demo/XCFit4DemoXCUIPoMTests/Extensions.swift +60 -0
  32. data/XCFit4Demo/XCFit4DemoXCUIPoMTests/HomeScreen.swift +23 -0
  33. data/XCFit4Demo/XCFit4DemoXCUIPoMTests/HomeScreenTest.swift +28 -0
  34. data/XCFit4Demo/XCFit4DemoXCUIPoMTests/Info.plist +22 -0
  35. data/XCFit4Demo/XCFit4DemoXCUIPoMTests/XCFit4DemoXCUIPoMTestsTestBase.swift +36 -0
  36. data/homebrew/xcfit +1 -1
  37. data/lib/XCFit/version.rb +1 -1
  38. metadata +33 -6
  39. data/Docs/InitialVersion.md +0 -340
  40. data/Docs/README_XCFit2.md +0 -572
  41. data/Docs/Xcode7.md +0 -273
  42. data/Docs/xcdoe7swift2.md +0 -311
data/lib/XCFit/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module XCFit
2
- VERSION = "3.1.5"
2
+ VERSION = "3.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcfit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.5
4
+ version: 3.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shashikant86
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-11 00:00:00.000000000 Z
11
+ date: 2017-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -68,18 +68,45 @@ files:
68
68
  - Cartfile
69
69
  - Cartfile.resolved
70
70
  - Dangerfile
71
- - Docs/InitialVersion.md
72
- - Docs/README_XCFit2.md
73
- - Docs/Xcode7.md
74
- - Docs/xcdoe7swift2.md
75
71
  - Gemfile
76
72
  - Gemfile.lock
77
73
  - LICENSE
78
74
  - Package.swift
75
+ - Pre-Defined_Steps/Cucumberish_Predefined_Steps.md
76
+ - Pre-Defined_Steps/XCFit_Predefined_Steps.md
79
77
  - README.md
80
78
  - Rakefile
81
79
  - XCFit.gemspec
82
80
  - XCFit.podspec
81
+ - XCFit4Demo/Cartfile
82
+ - XCFit4Demo/Cartfile.resolved
83
+ - XCFit4Demo/XCFit4Demo.xcodeproj/project.pbxproj
84
+ - XCFit4Demo/XCFit4Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
85
+ - XCFit4Demo/XCFit4Demo/AppDelegate.swift
86
+ - XCFit4Demo/XCFit4Demo/Assets.xcassets/AppIcon.appiconset/Contents.json
87
+ - XCFit4Demo/XCFit4Demo/Base.lproj/LaunchScreen.storyboard
88
+ - XCFit4Demo/XCFit4Demo/Base.lproj/Main.storyboard
89
+ - XCFit4Demo/XCFit4Demo/Info.plist
90
+ - XCFit4Demo/XCFit4Demo/ViewController.swift
91
+ - XCFit4Demo/XCFit4DemoCucumberTests/BaseScreen.swift
92
+ - XCFit4Demo/XCFit4DemoCucumberTests/CommonStepDefinitions.swift
93
+ - XCFit4Demo/XCFit4DemoCucumberTests/Extensions.swift
94
+ - XCFit4Demo/XCFit4DemoCucumberTests/Features/demo.feature
95
+ - XCFit4Demo/XCFit4DemoCucumberTests/HomeScreen.swift
96
+ - XCFit4Demo/XCFit4DemoCucumberTests/HomeScreenSteps.swift
97
+ - XCFit4Demo/XCFit4DemoCucumberTests/Hooks.swift
98
+ - XCFit4Demo/XCFit4DemoCucumberTests/Info.plist
99
+ - XCFit4Demo/XCFit4DemoCucumberTests/XCFit4DemoCucumberTests-Bridging-Header.h
100
+ - XCFit4Demo/XCFit4DemoCucumberTests/XCFit4DemoCucumberTests.h
101
+ - XCFit4Demo/XCFit4DemoCucumberTests/XCFit4DemoCucumberTests.m
102
+ - XCFit4Demo/XCFit4DemoCucumberTests/XCFit4DemoCucumberTests.swift
103
+ - XCFit4Demo/XCFit4DemoTests/Info.plist
104
+ - XCFit4Demo/XCFit4DemoTests/XCFit4DemoTests.swift
105
+ - XCFit4Demo/XCFit4DemoXCUIPoMTests/Extensions.swift
106
+ - XCFit4Demo/XCFit4DemoXCUIPoMTests/HomeScreen.swift
107
+ - XCFit4Demo/XCFit4DemoXCUIPoMTests/HomeScreenTest.swift
108
+ - XCFit4Demo/XCFit4DemoXCUIPoMTests/Info.plist
109
+ - XCFit4Demo/XCFit4DemoXCUIPoMTests/XCFit4DemoXCUIPoMTestsTestBase.swift
83
110
  - XCFit_Templates/XCFit/Cucumber Feature.xctemplate/TemplateIcon.png
84
111
  - XCFit_Templates/XCFit/Cucumber Feature.xctemplate/TemplateIcon@2x.png
85
112
  - XCFit_Templates/XCFit/Cucumber Feature.xctemplate/TemplateInfo.plist
@@ -1,340 +0,0 @@
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 : Xcode 8 + Swift 3
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, 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 [RubyGem](https://rubygems.org/gems/xcfit) and [CocoaPods](http://cocoadocs.org/docsets/XCFit).
9
-
10
- ### XCFit Features
11
- ***
12
- - You can now write Given When Then and Decision Table in Xcode !! YAY.. Thanks to Cucumberish and OCSlimProject ! And XCFit automated them !!
13
- - You can now write/Execute all your Acdeptance 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 !!
14
- - XCFit provides Xcode Templates to create new Cucumberish and Fitnesse targets which reduce hectic Xcode configuration steps. It's all automated in XCFit
15
- - One command to set all fully automated Xcode template for Cucumberish and Fitnesse targets
16
- - New Template to create Gherkin Feature file in Xcode
17
- - Automated [Cucumberish](https://github.com/Ahmed-Ali/Cucumberish) Setup in one command
18
- - Enhanced [OCSlimProject](https://github.com/paulstringer/OCSlimProject) templates and automated Fitnesse download process.
19
- - XCFit target templates are independent of native Xcode Test targets.
20
- - We can stiil use Apple's brand new XCUI Testing framework. Its native Xcode implementation, No Appium, Calabash etc etc
21
- - Setup Cucumberish and Fitnesse in Xcode within few minutes !!
22
-
23
- ***
24
-
25
- ### Xcode 7 Users
26
-
27
- If you are still XCode 7 users then please follow [this](https://github.com/Shashikant86/XCFit/blob/master/Docs/xcdoe7swift2.md) link for documentation
28
-
29
-
30
- ### Quick Demo with Example App
31
-
32
- You can clone the existing repo which has a demo app we can run Unit, Fitnesse and Cucumbertish Tests as XCTest
33
- ```
34
- $ git clone https://github.com/Shashikant86/XCFit
35
- $ cd XCFit/XCFitnesse
36
- $ open XCFitnesse.xcworkspace
37
- ```
38
- Run Unit, Fitnesse and Cucumberish test with Xcode. "cmd + U". We can execute it using Fastlane
39
-
40
-
41
- ```
42
- $ bundle install
43
- $ bundle exec fastlane xctest_fitnesse
44
- ```
45
-
46
-
47
- Watch this animated GIF for the steps below.
48
-
49
- ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/XCFitDemo.gif)
50
-
51
-
52
- Big Thanks to
53
- - [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!
54
- - [OCSlimProject](https://github.com/paulstringer/OCSlimProject) : Provide Xcode Templates to enable BDD with Decision Tables using Fitnesse
55
-
56
- XCFit automated configuration of these two guys.
57
-
58
- ### Version
59
- CocoaPods -- [XCFit-CocoaPods](http://cocoadocs.org/docsets/XCFit) : 0.1.0
60
-
61
- RubyGems -- [xcfit-RubyGem](https://rubygems.org/gems/xcfit) : 2.0.1
62
-
63
- ### Tech & Software Requirements
64
-
65
- XCFit uses a number of open source projects to work properly. You need to have following
66
-
67
- Hardware : You must have Mac Operating System with OSX/MacOS version > 10.9
68
-
69
- Software:
70
- * [Ruby](https://www.ruby-lang.org/en/) - Use [RVM](https://rvm.io/) for GEM management. Ideally Ruby > 2.X
71
- * [Xcode8](https://developer.apple.com/xcode/) - Ideally Xcode 8
72
- * [RubyGems](https://rubygems.org/) - RubyGem with [Cocoapods](https://cocoapods.org/) installed
73
- * [Curl on Mac](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/curl.1.html) - Might be pre-installed but worth double checking.
74
- * NodeJS and iOS-Sim
75
- * Ruby Packages : Xcpretty, Fastlane(Optional), Rake, Bundler.. Install with 'gem install <package_name>'
76
-
77
-
78
- ### Installation
79
-
80
- XCFit requires [RubyGems](https://rubygems.org/) to run.
81
-
82
- You need Gulp installed globally:
83
-
84
-
85
- $ gem install xcfit
86
-
87
- Now you are good to get started with XCFit for now. Later we also need to install XCFit Pod.
88
-
89
- # Usage
90
- Now that you can execute 'xcfit' command from your terminal/iTerm etc etc. Example Output Looks like this :
91
-
92
- ```
93
- $ xcfit
94
- Tasks:
95
- xcfit get_cucumberish VERSION # Downloads Cucumberish version and Create Features directory. You must execute this from Cucumberish Xcode Target directory
96
- xcfit get_fitnesse # Download Fitnesse JAR file from Internet. You must execute this from Xcode Fitnesse Acceptance Test Xcode Target directory
97
- xcfit help [TASK] # Describe available tasks or one specific task
98
- xcfit set_xcode_templates # Generate All Xcode Templates for the Gherkin Feature Files & targets for Cucumberish and Fitnesse
99
- xcfit version # Get the current version number
100
-
101
- ```
102
-
103
- ## Setup Xcode Templates
104
-
105
- In existing app or brand new app, we have to enable the Xcode templates for files and targets to speed up the things. Run following command from your terminal
106
-
107
-
108
- ```sh
109
- $ xcfit set_xcode_templates
110
-
111
- ```
112
-
113
- - This will add couple of templates to your Xcode for iOS and macOS apps. In your app if you go to 'File--->New--->Target'
114
-
115
- You will see new option for iOS and OSX i.e 'XCFit'. Once Clicked on it. You will see Cucumberish UI and Fitnesse Acceptance Tests targets. As shown
116
-
117
- ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/new_targets_xcode8.png)
118
-
119
- - Once Clicked on the target e.g 'Cucumberish UI Test Bundle' Xcode will create UI testing target with all the required files with Bridging hrader for Cucumberish UI Testing.
120
- Once Clicked on the target e.g 'Fitnesse Acceptance Test Bundle' Xcode will create UI tAcceptance test with all the required files with Bridging headers for the Fitnesse Acceptance Test. We will see that in details soon.
121
-
122
- - This script also set new file type in Xcode to create new Gherking feature file
123
-
124
- ## Setting up Cucumberish UI Target
125
-
126
- Few Steps to setup BDD Styles in Xcode8
127
-
128
- ##### Add New Target for Cucumberish
129
-
130
- - Add new target iOS/macOS project and Select "File -> New -> Target -> XCFit -> Cucumberish UI Test Bundle". Give it a name you like e.g CucumberishUITests
131
-
132
- Now that Xcode has created brand new target with all required Swift and Objective-C files to run Cucumberish. All Xcode setting has been done by the Xcode Template.
133
- ####### Link Target Application
134
- The most important thing is link your target to application to test. Cucumberish target 'General' setting select 'Testing -> Target To Test' and configure scheme to add Cucumeerish UI target to Test
135
-
136
- ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/LinkTargetTestApp.png)
137
-
138
- #### Cucumberish Page Object Pattern Directory Structure
139
-
140
- Now that, you can observe that new target has nice directory structure following [Page Object Pattern](http://martinfowler.com/bliki/PageObject.html)
141
-
142
- ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/DirectoryStructure.png)
143
-
144
- ##### Download Cucumberish in the target
145
-
146
- This can be done in two ways. By directly downloading contents of "Cucumberish" directory into the target directory or using Cocoapods.
147
- ###### Using Direct Download with XCFit
148
- - Now that you have to CD into the Cucumberish target directory .eg CucumberishUITests
149
-
150
- ```sh
151
- $ cd $_YOUR_CUCUMBERISH_TARGET_DIR
152
- $ xcfit get_cucumberish 1.0.0
153
- ```
154
- This will download Cucumberish directory from version 1.0.0 and also create 'Features' directory. You can then reference those directory in Xcode. For "Cucumberish" directory select 'Copy if needed and Create Group' and for the "Features" directory select don't create group or Copy if needed. Just " create folder reference"
155
-
156
- ###### Using Cocoapods
157
-
158
- - In your Podfile, add following Pod entry and update/install pod
159
-
160
- ```ruby
161
- target '$_YOUR_CUCUMBERISH_TARGET' do
162
- pod 'Cucumberish', :git => 'https://github.com/Ahmed-Ali/Cucumberish'
163
- end
164
- ```
165
-
166
-
167
-
168
- ```sh
169
- $ pod update
170
- ```
171
-
172
-
173
- ##### Create Cucumber Features - Gherkin
174
- Now Add sample 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
175
-
176
- ```
177
- Feature: Demo App Feature
178
-
179
- Scenario: Demo Scenario
180
-
181
- Given the app is running
182
-
183
- ```
184
-
185
- ##### Add Target To Test
186
-
187
- - Finally, Run Your Test from Cucumberish Target by Pressing 'CMD+U'
188
-
189
- You are done !!
190
-
191
- Look how easy it is !
192
-
193
- ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/POM_Cucumberish.gif)
194
-
195
-
196
- You can add more feature/Scenarios and implement steps definitions inside your Swift File. [Ahmed-Ali](https://github.com/Ahmed-Ali) creator of Cucumberish already implemented useful pre-defined steps have a look at this [Swift file](https://github.com/Ahmed-Ali/Cucumberish/blob/master/CucumberishExample/CucumberishExampleUITests/CCIStepDefinitions.swift). You are free to try Page Object Pattern and all other crazy stuff to abstract and refactor your Swift code.
197
-
198
-
199
- ## Setting up Fitnesse Acceptance Target with XCTest
200
-
201
- You can also setup Fitnesse Acceptance Tests but you need to use Cocoapods for this target.
202
-
203
- You can find detailed blog post on [Dzone](https://dzone.com/articles/integrate-fitnesse-with-xctest-using-xcode8)
204
-
205
- #### Add Acceptance and Acceptance Unit Test Target to Project
206
-
207
- 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.
208
-
209
- ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/targets.gif)
210
-
211
- #### Add Pod Dependencies
212
- We need to create a “Podfile” at the root of the project with the following content.
213
-
214
- ```ruby
215
- target 'AcceptanceTests' do
216
- pod 'OCSlimProject'
217
- end
218
- target 'AcceptanceUnitTests' do
219
- pod 'OCSlimProjectTestBundleSupport'
220
- end
221
- ```
222
-
223
- Now, we can run ‘pod install’ at this stage and close the current Xcode session and open project workspace.
224
-
225
- ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/pod_install.gif)
226
-
227
- #### Build Acceptance Tests Target
228
- 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
229
-
230
- 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.
231
-
232
- ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/build_acceptace.gif)
233
-
234
- #### Test AcceptanceUnitTests Target
235
-
236
- Now if you select “AcceptanceUnitTarget” and press CMD+U.
237
-
238
- ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/RunXCUITest.gif)
239
-
240
-
241
- 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.
242
-
243
-
244
- ### Taking Control with Bundler, Fastlane, and Trainer
245
-
246
- Now that , we have seen how to run 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
247
-
248
- ```ruby
249
- source "https://rubygems.org"
250
- gem 'cocoapods'
251
- gem 'fastlane' plugins_path = File.join(File.dirname(__FILE__), '.', 'Pluginfile') eval(File.read(plugins_path), binding) if File.exist?(plugins_path
252
- ```
253
-
254
- Let’s also create directory “fastlane” and make “Fastfile” with following content
255
-
256
- ```ruby
257
-
258
- fastlane_version "1.104.0"
259
- default_platform :ios
260
- platform :ios do
261
- before_all do
262
- system "rm -rf ../test_reports/"
263
- system "bundle install"
264
- system "pod install"
265
- system "bundle exec fastlane add_plugin trainer"
266
- end
267
- desc "Runs all the Unit tests and Fitnesse Aceptance Tests"
268
- lane :xctest_fitnesse do
269
- scan(scheme: "FitnesseXCTestDemo",
270
- destination: 'platform=iOS Simulator,name=iPhone 7 Plus,OS=10.0',
271
- output_directory: "test_reports/",
272
- output_types: "html",
273
- fail_build: false )
274
- trainer(output_directory: "test_reports/trainer_report/")
275
- end
276
- end
277
- ```
278
-
279
- Now we will create a “fastlane/PluginFile” to add “trainer” plugin.
280
-
281
- ```ruby
282
- gem 'fastlane-plugin-trainer'
283
-
284
- ```
285
-
286
- After running “bundle install” we should be able to run those test from command line like this :
287
-
288
- ![image](https://github.com/Shashikant86/XCFit-GIFS/blob/master/xcfitnesse.gif)
289
-
290
-
291
- You can watch YouTube video of XCFTest-Fitnesse [here](https://www.youtube.com/watch?v=xqvy1vN87e8)
292
-
293
-
294
- # Video Demo
295
-
296
- ### XCTest Fitnesse Demo
297
-
298
- [![IMAGE ALT TEXT HERE](http://img.youtube.com/vi/xqvy1vN87e8/0.jpg)](http://www.youtube.com/watch?v=xxqvy1vN87e8)
299
-
300
-
301
- ## Author
302
-
303
- Shashikant86, shashikant.jagtap@icloud.com
304
-
305
- # TODO
306
-
307
- * Swift Implementation of Gherkin Parser
308
- * Cocoapods free installation. Carthage or Swift Package Manager once ready
309
- * Setting up XCFit on Apple's own CI Xcode Server
310
-
311
- ## LICENSE
312
-
313
- Copyright © 2014 Shashikant Jagtap, http://shashikantjagtap.net
314
-
315
- Permission is hereby granted, free of charge, to any person obtaining
316
- a copy of this software and associated documentation files (the
317
- "Software"), to deal in the Software without restriction, including
318
- without limitation the rights to use, copy, modify, merge, publish,
319
- distribute, sublicense, and/or sell copies of the Software, and to
320
- permit persons to whom the Software is furnished to do so, subject to
321
- the following conditions:
322
-
323
- The above copyright notice and this permission notice shall be
324
- included in all copies or substantial portions of the Software.
325
-
326
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
327
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
328
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
329
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
330
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
331
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
332
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
333
-
334
- ## Contributing
335
-
336
- 1. Fork it ( https://github.com/Shashikant86/XCFit/fork )
337
- 2. Create your feature branch (`git checkout -b my-new-feature`)
338
- 3. Commit your changes (`git commit -am 'Add some feature'`)
339
- 4. Push to the branch (`git push origin my-new-feature`)
340
- 5. Create a new Pull Request
@@ -1,572 +0,0 @@
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 &amp; 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