SlideShare a Scribd company logo
Agile Swift
Godfrey Nolan
RIIS LLC
Agenda
Agile Testing Benefits
Catch more mistakes
Confidently make more changes
Built in regression testing
Extend the life of your codebase
Better predicability & reliability
Agile Swift
Swift Unit Test - XCTest
Swift Unit Test - XCTest
Unit Testing Assertions
Unit Testing Code Coverage
Unit Testing Code Coverage
Unit Testing Code Coverage
$ gem install slather
$ slather coverage --html --scheme XcodeSchemeName path/to/project.xcodeproj
$ slather coverage --html --scheme Calculator Calculator/Calculator.xcodeproj
API Testing - Postman
API Testing - Newman
Swift GUI Testing - XCUI
Swift GUI Testing
Putting It All Together
Putting It All Together
Putting It All Together
1. Download the Jenkins Mac OS X native package from http://jenkins-ci.org.
2. Double click the .pkg file to install Jenkins.
3. Once done, your browser will open to http://localhost:8080 where Jenkins lives.
4. Make the Jenkins user an admin:
sudo dseditgroup -o edit -a jenkins -t user admin
5. Add the Jenkins user to the developer group:
sudo dscl . append /Groups/_developer GroupMembership jenkins
6. Make the Jenkins user automatically login when the computer is restarted
7. unload Jenkins as a Daemon:
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
8. move the .plist file, which defines how Jenkins will run, to the LaunchAgents folder:
sudo mv /Library/LaunchDaemons/org.jenkins-ci.plist /Library/LaunchAgents/
9. Edit the plist file:
sudo vim /Library/LaunchAgents/org.jenkins-ci.plist
/* Remove the following lines */
<key>SessionCreate</key
<true />
10. reload the Launch Agent to restart Jenkins:
sudo launchctl load /Library/LaunchAgents/org.jenkins-ci.plist
FIRST Principles
F(ast)
I(solated)
R(epeatable)
S(elf-verifying)
T(imely) i.e. TDD not TAD
FIRST Principles - Fast
FIRST Principles - Fast
FIRST Principles - Isolated
when(methodIsCalled).thenReturn(aValue);
// Cuckoo
stub(mock) { stub in
when(stub.readWriteProperty.get).thenReturn(10)
}
1. Create your project with model class and test class.
2. Run pod init
3. Edit the generated podfile and add pod “Cuckoo” as a test target.
4. Run pod install.
5. Close the project and reopen the workspace.
6. Click on the project folder then choose Test Target ➤ Build Phases.
7. Click + and choose New Run Script Phase.
8. Add Listing to the Run Script section, making sure to modify the
input files that you want to mock.
9. Build the project.
10. Run the tests.
11. Drag and drop GeneratedMocks.swift into the test section.
12. Uncomment out your mocked tests
13. Run the mocked tests.
Isolated - Cuckoo
Isolated - Cuckoo
# Define output file; change "${PROJECT_NAME}Tests" to your test's
root source folder, if it's not the default name
OUTPUT_FILE="./${PROJECT_NAME}Tests/GeneratedMocks.swift"
echo "Generated Mocks File = ${OUTPUT_FILE}"
# Define input directory; change "${PROJECT_NAME}" to your project's root
source folder, if it's not the default name
INPUT_DIR="./${PROJECT_NAME}"
echo "Mocks Input Directory = ${INPUT_DIR}"
# Generate mock files; include as many input files as you'd like to create mocks for
${PODS_ROOT}/Cuckoo/run generate --testable "${PROJECT_NAME}" 
--output "${OUTPUT_FILE}" 
"${INPUT_DIR}/FileName1.swift" 
"${INPUT_DIR}/FileName2.swift" 
"${INPUT_DIR}/FileName3.swift"
# ... and so forth
Isolated - Cuckoo
FIRST Principle - Repeatable
FIRST Prin - Self-Verifying
FIRST Principles - Timely
Sample App
Sample App
Sample App - Unit Test
func testParseRoutes() {
let mock = MockJSONfetcher()
stub(mock) { mock in
when(mock.callApi(url: any(), completion: anyClosure())).then { url, closure in
closure(self.testRouteJson)
}
}
mock.callApi(url: url) { data in
XCTAssertEqual(data, self.testRouteJson)
let parser = customJSONparser(companyIndex: 1)
let route = Route(name: "FORT ST-EUREKA RD",
direction1: "Northbound",
direction2: "Southbound", id: 1, routeId: "125")
XCTAssertEqual(parser.getRoutes(fromJSONString: data), [route])
}
}
xcodebuild test -workspace ETAMock.xcworkspace -scheme ETAMock
-destination 'platform=iOS Simulator, name=iPhone 7 Plus'
Sample App - Unit Test
# Define output file; change "${PROJECT_NAME}Tests" to your test's root source folder, if it's not the default name
OUTPUT_FILE="./${PROJECT_NAME}Tests/GeneratedMocks.swift"
echo "Generated Mocks File = ${OUTPUT_FILE}"
# Define input directory; change "${PROJECT_NAME}" to your project's root source folder, if it's not the default name
INPUT_DIR="./${PROJECT_NAME}"
echo "Mocks Input Directory = ${INPUT_DIR}"
# Generate mock files; include as many input files as you'd like to create mocks for
${PODS_ROOT}/Cuckoo/run generate --testable "${PROJECT_NAME}" 
--output "${OUTPUT_FILE}" 
"${INPUT_DIR}/JSONFetcher.swift"
# ... and so forth
# After running once, locate `GeneratedMocks.swift` and drag it into your Xcode test target group
Sample App - API Test
Sample App - API Test
newman run ETAJson.postman_collection
Sample App - API Test
Sample App - GUI Test
func testExample() {
let app = XCUIApplication()
let tablesQuery = app.tables
tablesQuery.staticTexts["Smart"].tap()
tablesQuery.staticTexts["SOUTHSHORE"].tap()
app.buttons["Southbound"].tap()
XCTAssert(tablesQuery.staticTexts["JEFFERSON + SOUTHFIELD"].exists)
app.navigationBars["ETAMock.StopsView"].children(matching: .button)
.matching(identifier: "Back").element(boundBy: 0).tap()
tablesQuery.staticTexts["MICHIGAN AVENUE LOCAL"].tap()
app.buttons["Westbound"].tap()
XCTAssert(tablesQuery.staticTexts["MICHIGAN + CASS"].exists)
}
xcodebuild build -workspace ETAMock.xcworkspace -scheme ETAMock
-destination 'platform=iOS Simulator, name=iPhone 7 Plus'
Sample App - Jenkins
Sample App - Jenkins
Sample App - Jenkins
SonarQube - Jenkins
SonarQube - Jenkins
SonarQube - Jenkins
Swift on Linux
Swift on Linux
URLshttp://riis.com/blog
https://getpostman.com
https://github.com/postmanlabs/newman
https://github.com/Brightify/Cuckoo
https://jenkins.io
http://www.cimgf.com/2015/05/26/setting-up-jenkins-ci-on-a-mac-2/
https://github.com/gnolanltu/ETAMock
https://slides.com/godfreynolan/agileswiftmeetup
https://sonarqube.org
https://github.com/fastlane/fastlane
CONTACT INFO
godfrey@riis.com
@godfreynolan
http://bit.ly/AgileSwiftWorkshop

More Related Content

What's hot

멀티플랫폼 앱 개발과 테스팅
멀티플랫폼 앱 개발과 테스팅멀티플랫폼 앱 개발과 테스팅
멀티플랫폼 앱 개발과 테스팅
WooKyoung Noh
 
Como NÃO testar o seu projeto de Software. DevDay 2014
Como NÃO testar o seu projeto de Software. DevDay 2014Como NÃO testar o seu projeto de Software. DevDay 2014
Como NÃO testar o seu projeto de Software. DevDay 2014
alexandre freire
 
Introduzione al TDD
Introduzione al TDDIntroduzione al TDD
Introduzione al TDD
Andrea Francia
 
Intro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSIntro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJS
Jim Lynch
 
Calculon
CalculonCalculon
Unit testing with mocha
Unit testing with mochaUnit testing with mocha
Unit testing with mocha
Revath S Kumar
 
Automated User Tests with Apache Flex
Automated User Tests with Apache FlexAutomated User Tests with Apache Flex
Automated User Tests with Apache Flex
Gert Poppe
 
JavaFX8 TestFX - CDI
JavaFX8   TestFX - CDIJavaFX8   TestFX - CDI
JavaFX8 TestFX - CDI
Sven Ruppert
 
Tdd iPhone For Dummies
Tdd iPhone For DummiesTdd iPhone For Dummies
Tdd iPhone For Dummies
Giordano Scalzo
 
Unit Testing in Kotlin
Unit Testing in KotlinUnit Testing in Kotlin
Unit Testing in Kotlin
Egor Andreevich
 
Keeping 100m+ users happy: How we test Shazam on Android
Keeping 100m+ users happy: How we test Shazam on AndroidKeeping 100m+ users happy: How we test Shazam on Android
Keeping 100m+ users happy: How we test Shazam on AndroidIordanis (Jordan) Giannakakis
 
Kotlinでテストコードを書く
Kotlinでテストコードを書くKotlinでテストコードを書く
Kotlinでテストコードを書く
Shoichi Matsuda
 
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava TalkUnit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
Long Weekend LLC
 
Testing javascript in the frontend
Testing javascript in the frontendTesting javascript in the frontend
Testing javascript in the frontend
Frederic CABASSUT
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with Jest
Michał Pierzchała
 
Unit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon GaliciaUnit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon Galicia
Robot Media
 
Quick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using JasmineQuick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using Jasmine
Gil Fink
 
Dependency Injection with CDI in 15 minutes
Dependency Injection with CDI in 15 minutesDependency Injection with CDI in 15 minutes
Dependency Injection with CDI in 15 minutes
Antonio Goncalves
 

What's hot (20)

멀티플랫폼 앱 개발과 테스팅
멀티플랫폼 앱 개발과 테스팅멀티플랫폼 앱 개발과 테스팅
멀티플랫폼 앱 개발과 테스팅
 
Como NÃO testar o seu projeto de Software. DevDay 2014
Como NÃO testar o seu projeto de Software. DevDay 2014Como NÃO testar o seu projeto de Software. DevDay 2014
Como NÃO testar o seu projeto de Software. DevDay 2014
 
Introduzione al TDD
Introduzione al TDDIntroduzione al TDD
Introduzione al TDD
 
Intro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSIntro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJS
 
Calculon
CalculonCalculon
Calculon
 
Unit testing with mocha
Unit testing with mochaUnit testing with mocha
Unit testing with mocha
 
Automated User Tests with Apache Flex
Automated User Tests with Apache FlexAutomated User Tests with Apache Flex
Automated User Tests with Apache Flex
 
JavaFX8 TestFX - CDI
JavaFX8   TestFX - CDIJavaFX8   TestFX - CDI
JavaFX8 TestFX - CDI
 
Tdd iPhone For Dummies
Tdd iPhone For DummiesTdd iPhone For Dummies
Tdd iPhone For Dummies
 
Unit Testing in Kotlin
Unit Testing in KotlinUnit Testing in Kotlin
Unit Testing in Kotlin
 
My java file
My java fileMy java file
My java file
 
Keeping 100m+ users happy: How we test Shazam on Android
Keeping 100m+ users happy: How we test Shazam on AndroidKeeping 100m+ users happy: How we test Shazam on Android
Keeping 100m+ users happy: How we test Shazam on Android
 
Kotlinでテストコードを書く
Kotlinでテストコードを書くKotlinでテストコードを書く
Kotlinでテストコードを書く
 
Unit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava TalkUnit Testing in iOS - Ninjava Talk
Unit Testing in iOS - Ninjava Talk
 
Testing javascript in the frontend
Testing javascript in the frontendTesting javascript in the frontend
Testing javascript in the frontend
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with Jest
 
Unit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon GaliciaUnit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon Galicia
 
Python testing
Python  testingPython  testing
Python testing
 
Quick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using JasmineQuick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using Jasmine
 
Dependency Injection with CDI in 15 minutes
Dependency Injection with CDI in 15 minutesDependency Injection with CDI in 15 minutes
Dependency Injection with CDI in 15 minutes
 

Similar to Agile Swift

Gradle
GradleGradle
Real world cross-platform testing
Real world cross-platform testingReal world cross-platform testing
Real world cross-platform testingPeter Edwards
 
Spock
SpockSpock
10 Cool Facts about Gradle
10 Cool Facts about Gradle10 Cool Facts about Gradle
10 Cool Facts about GradleEvgeny Goldin
 
GradleFX
GradleFXGradleFX
Infinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum Android Talks #17 - Testing your Android applications by Ivan KustInfinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum
 
JCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop LabsJCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop Labs
Simon Su
 
Unit testing
Unit testingUnit testing
Unit testing
davidahaskins
 
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan KustAndroid Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
Infinum
 
Spocktacular Testing - Russel Winder
Spocktacular Testing - Russel WinderSpocktacular Testing - Russel Winder
Spocktacular Testing - Russel Winder
JAXLondon2014
 
Spocktacular Testing
Spocktacular TestingSpocktacular Testing
Spocktacular Testing
Russel Winder
 
Testing NodeJS with Mocha, Should, Sinon, and JSCoverage
Testing NodeJS with Mocha, Should, Sinon, and JSCoverageTesting NodeJS with Mocha, Should, Sinon, and JSCoverage
Testing NodeJS with Mocha, Should, Sinon, and JSCoveragemlilley
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
Ortus Solutions, Corp
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!
Roberto Franchini
 
Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01Tino Isnich
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e bigAndy Peterson
 
Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
Suman Sourav
 
A few good JavaScript development tools
A few good JavaScript development toolsA few good JavaScript development tools
A few good JavaScript development tools
Simon Kim
 
Testing with PostgreSQL
Testing with PostgreSQLTesting with PostgreSQL
Testing with PostgreSQL
Shawn Sorichetti
 

Similar to Agile Swift (20)

Gradle
GradleGradle
Gradle
 
Real world cross-platform testing
Real world cross-platform testingReal world cross-platform testing
Real world cross-platform testing
 
Spock
SpockSpock
Spock
 
10 Cool Facts about Gradle
10 Cool Facts about Gradle10 Cool Facts about Gradle
10 Cool Facts about Gradle
 
GradleFX
GradleFXGradleFX
GradleFX
 
Infinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum Android Talks #17 - Testing your Android applications by Ivan KustInfinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum Android Talks #17 - Testing your Android applications by Ivan Kust
 
JCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop LabsJCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop Labs
 
Unit testing
Unit testingUnit testing
Unit testing
 
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan KustAndroid Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
 
Spocktacular Testing - Russel Winder
Spocktacular Testing - Russel WinderSpocktacular Testing - Russel Winder
Spocktacular Testing - Russel Winder
 
Spocktacular Testing
Spocktacular TestingSpocktacular Testing
Spocktacular Testing
 
Testing NodeJS with Mocha, Should, Sinon, and JSCoverage
Testing NodeJS with Mocha, Should, Sinon, and JSCoverageTesting NodeJS with Mocha, Should, Sinon, and JSCoverage
Testing NodeJS with Mocha, Should, Sinon, and JSCoverage
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
 
A few good JavaScript development tools
A few good JavaScript development toolsA few good JavaScript development tools
A few good JavaScript development tools
 
Testing with PostgreSQL
Testing with PostgreSQLTesting with PostgreSQL
Testing with PostgreSQL
 

More from Godfrey Nolan

Counting Cars with Drones
Counting Cars with DronesCounting Cars with Drones
Counting Cars with Drones
Godfrey Nolan
 
Customising QGroundControl
Customising QGroundControlCustomising QGroundControl
Customising QGroundControl
Godfrey Nolan
 
DJI Payload SDK
DJI Payload SDKDJI Payload SDK
DJI Payload SDK
Godfrey Nolan
 
Parrot Tutorials in Kotlin
Parrot Tutorials in KotlinParrot Tutorials in Kotlin
Parrot Tutorials in Kotlin
Godfrey Nolan
 
DJI Mobile SDK Tutorials in kotlin
DJI Mobile SDK Tutorials in kotlinDJI Mobile SDK Tutorials in kotlin
DJI Mobile SDK Tutorials in kotlin
Godfrey Nolan
 
Drone sdk showdown
Drone sdk showdownDrone sdk showdown
Drone sdk showdown
Godfrey Nolan
 
AI/ML in drones
AI/ML in dronesAI/ML in drones
AI/ML in drones
Godfrey Nolan
 
Getting started with tensor flow datasets
Getting started with tensor flow datasets Getting started with tensor flow datasets
Getting started with tensor flow datasets
Godfrey Nolan
 
Using ML to make your UI tests more robust
Using ML to make your UI tests more robustUsing ML to make your UI tests more robust
Using ML to make your UI tests more robust
Godfrey Nolan
 
Java best practices
Java best practicesJava best practices
Java best practices
Godfrey Nolan
 
Counting sheep with Drones and AI
Counting sheep with Drones and AICounting sheep with Drones and AI
Counting sheep with Drones and AI
Godfrey Nolan
 
Writing Secure Mobile Apps for Drones
Writing Secure Mobile Apps for DronesWriting Secure Mobile Apps for Drones
Writing Secure Mobile Apps for Drones
Godfrey Nolan
 
Android Device Labs
Android Device LabsAndroid Device Labs
Android Device Labs
Godfrey Nolan
 
The Day We Infected Ourselves with Ransomware
The Day We Infected Ourselves with RansomwareThe Day We Infected Ourselves with Ransomware
The Day We Infected Ourselves with Ransomware
Godfrey Nolan
 
Android Refactoring
Android RefactoringAndroid Refactoring
Android Refactoring
Godfrey Nolan
 
Agile mobile
Agile mobileAgile mobile
Agile mobile
Godfrey Nolan
 
From Maps to Apps the Future of Drone Technology
From Maps to Apps the Future of Drone TechnologyFrom Maps to Apps the Future of Drone Technology
From Maps to Apps the Future of Drone Technology
Godfrey Nolan
 
Tableau 10 and quickbooks
Tableau 10 and quickbooksTableau 10 and quickbooks
Tableau 10 and quickbooks
Godfrey Nolan
 
Network graphs in tableau
Network graphs in tableauNetwork graphs in tableau
Network graphs in tableau
Godfrey Nolan
 
Bulletproof
BulletproofBulletproof
Bulletproof
Godfrey Nolan
 

More from Godfrey Nolan (20)

Counting Cars with Drones
Counting Cars with DronesCounting Cars with Drones
Counting Cars with Drones
 
Customising QGroundControl
Customising QGroundControlCustomising QGroundControl
Customising QGroundControl
 
DJI Payload SDK
DJI Payload SDKDJI Payload SDK
DJI Payload SDK
 
Parrot Tutorials in Kotlin
Parrot Tutorials in KotlinParrot Tutorials in Kotlin
Parrot Tutorials in Kotlin
 
DJI Mobile SDK Tutorials in kotlin
DJI Mobile SDK Tutorials in kotlinDJI Mobile SDK Tutorials in kotlin
DJI Mobile SDK Tutorials in kotlin
 
Drone sdk showdown
Drone sdk showdownDrone sdk showdown
Drone sdk showdown
 
AI/ML in drones
AI/ML in dronesAI/ML in drones
AI/ML in drones
 
Getting started with tensor flow datasets
Getting started with tensor flow datasets Getting started with tensor flow datasets
Getting started with tensor flow datasets
 
Using ML to make your UI tests more robust
Using ML to make your UI tests more robustUsing ML to make your UI tests more robust
Using ML to make your UI tests more robust
 
Java best practices
Java best practicesJava best practices
Java best practices
 
Counting sheep with Drones and AI
Counting sheep with Drones and AICounting sheep with Drones and AI
Counting sheep with Drones and AI
 
Writing Secure Mobile Apps for Drones
Writing Secure Mobile Apps for DronesWriting Secure Mobile Apps for Drones
Writing Secure Mobile Apps for Drones
 
Android Device Labs
Android Device LabsAndroid Device Labs
Android Device Labs
 
The Day We Infected Ourselves with Ransomware
The Day We Infected Ourselves with RansomwareThe Day We Infected Ourselves with Ransomware
The Day We Infected Ourselves with Ransomware
 
Android Refactoring
Android RefactoringAndroid Refactoring
Android Refactoring
 
Agile mobile
Agile mobileAgile mobile
Agile mobile
 
From Maps to Apps the Future of Drone Technology
From Maps to Apps the Future of Drone TechnologyFrom Maps to Apps the Future of Drone Technology
From Maps to Apps the Future of Drone Technology
 
Tableau 10 and quickbooks
Tableau 10 and quickbooksTableau 10 and quickbooks
Tableau 10 and quickbooks
 
Network graphs in tableau
Network graphs in tableauNetwork graphs in tableau
Network graphs in tableau
 
Bulletproof
BulletproofBulletproof
Bulletproof
 

Recently uploaded

How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
Gal Baras
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Sanjeev Rampal
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
laozhuseo02
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
natyesu
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
Arif0071
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
nirahealhty
 
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
TristanJasperRamos
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
JeyaPerumal1
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
Himani415946
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
JungkooksNonexistent
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
ShahulHameed54211
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
laozhuseo02
 

Recently uploaded (16)

How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
 
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 

Agile Swift

  • 3.
  • 4. Agile Testing Benefits Catch more mistakes Confidently make more changes Built in regression testing Extend the life of your codebase Better predicability & reliability
  • 6. Swift Unit Test - XCTest
  • 7. Swift Unit Test - XCTest
  • 8.
  • 9.
  • 11. Unit Testing Code Coverage
  • 12. Unit Testing Code Coverage
  • 13.
  • 14. Unit Testing Code Coverage $ gem install slather $ slather coverage --html --scheme XcodeSchemeName path/to/project.xcodeproj $ slather coverage --html --scheme Calculator Calculator/Calculator.xcodeproj
  • 15. API Testing - Postman
  • 16. API Testing - Newman
  • 18.
  • 20. Putting It All Together
  • 21. Putting It All Together
  • 22. Putting It All Together 1. Download the Jenkins Mac OS X native package from http://jenkins-ci.org. 2. Double click the .pkg file to install Jenkins. 3. Once done, your browser will open to http://localhost:8080 where Jenkins lives. 4. Make the Jenkins user an admin: sudo dseditgroup -o edit -a jenkins -t user admin 5. Add the Jenkins user to the developer group: sudo dscl . append /Groups/_developer GroupMembership jenkins 6. Make the Jenkins user automatically login when the computer is restarted 7. unload Jenkins as a Daemon: sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist 8. move the .plist file, which defines how Jenkins will run, to the LaunchAgents folder: sudo mv /Library/LaunchDaemons/org.jenkins-ci.plist /Library/LaunchAgents/ 9. Edit the plist file: sudo vim /Library/LaunchAgents/org.jenkins-ci.plist /* Remove the following lines */ <key>SessionCreate</key <true /> 10. reload the Launch Agent to restart Jenkins: sudo launchctl load /Library/LaunchAgents/org.jenkins-ci.plist
  • 26. FIRST Principles - Isolated when(methodIsCalled).thenReturn(aValue); // Cuckoo stub(mock) { stub in when(stub.readWriteProperty.get).thenReturn(10) }
  • 27. 1. Create your project with model class and test class. 2. Run pod init 3. Edit the generated podfile and add pod “Cuckoo” as a test target. 4. Run pod install. 5. Close the project and reopen the workspace. 6. Click on the project folder then choose Test Target ➤ Build Phases. 7. Click + and choose New Run Script Phase. 8. Add Listing to the Run Script section, making sure to modify the input files that you want to mock. 9. Build the project. 10. Run the tests. 11. Drag and drop GeneratedMocks.swift into the test section. 12. Uncomment out your mocked tests 13. Run the mocked tests. Isolated - Cuckoo
  • 29. # Define output file; change "${PROJECT_NAME}Tests" to your test's root source folder, if it's not the default name OUTPUT_FILE="./${PROJECT_NAME}Tests/GeneratedMocks.swift" echo "Generated Mocks File = ${OUTPUT_FILE}" # Define input directory; change "${PROJECT_NAME}" to your project's root source folder, if it's not the default name INPUT_DIR="./${PROJECT_NAME}" echo "Mocks Input Directory = ${INPUT_DIR}" # Generate mock files; include as many input files as you'd like to create mocks for ${PODS_ROOT}/Cuckoo/run generate --testable "${PROJECT_NAME}" --output "${OUTPUT_FILE}" "${INPUT_DIR}/FileName1.swift" "${INPUT_DIR}/FileName2.swift" "${INPUT_DIR}/FileName3.swift" # ... and so forth Isolated - Cuckoo
  • 30. FIRST Principle - Repeatable
  • 31. FIRST Prin - Self-Verifying
  • 35. Sample App - Unit Test func testParseRoutes() { let mock = MockJSONfetcher() stub(mock) { mock in when(mock.callApi(url: any(), completion: anyClosure())).then { url, closure in closure(self.testRouteJson) } } mock.callApi(url: url) { data in XCTAssertEqual(data, self.testRouteJson) let parser = customJSONparser(companyIndex: 1) let route = Route(name: "FORT ST-EUREKA RD", direction1: "Northbound", direction2: "Southbound", id: 1, routeId: "125") XCTAssertEqual(parser.getRoutes(fromJSONString: data), [route]) } } xcodebuild test -workspace ETAMock.xcworkspace -scheme ETAMock -destination 'platform=iOS Simulator, name=iPhone 7 Plus'
  • 36. Sample App - Unit Test # Define output file; change "${PROJECT_NAME}Tests" to your test's root source folder, if it's not the default name OUTPUT_FILE="./${PROJECT_NAME}Tests/GeneratedMocks.swift" echo "Generated Mocks File = ${OUTPUT_FILE}" # Define input directory; change "${PROJECT_NAME}" to your project's root source folder, if it's not the default name INPUT_DIR="./${PROJECT_NAME}" echo "Mocks Input Directory = ${INPUT_DIR}" # Generate mock files; include as many input files as you'd like to create mocks for ${PODS_ROOT}/Cuckoo/run generate --testable "${PROJECT_NAME}" --output "${OUTPUT_FILE}" "${INPUT_DIR}/JSONFetcher.swift" # ... and so forth # After running once, locate `GeneratedMocks.swift` and drag it into your Xcode test target group
  • 37.
  • 38. Sample App - API Test
  • 39. Sample App - API Test newman run ETAJson.postman_collection
  • 40. Sample App - API Test
  • 41. Sample App - GUI Test func testExample() { let app = XCUIApplication() let tablesQuery = app.tables tablesQuery.staticTexts["Smart"].tap() tablesQuery.staticTexts["SOUTHSHORE"].tap() app.buttons["Southbound"].tap() XCTAssert(tablesQuery.staticTexts["JEFFERSON + SOUTHFIELD"].exists) app.navigationBars["ETAMock.StopsView"].children(matching: .button) .matching(identifier: "Back").element(boundBy: 0).tap() tablesQuery.staticTexts["MICHIGAN AVENUE LOCAL"].tap() app.buttons["Westbound"].tap() XCTAssert(tablesQuery.staticTexts["MICHIGAN + CASS"].exists) } xcodebuild build -workspace ETAMock.xcworkspace -scheme ETAMock -destination 'platform=iOS Simulator, name=iPhone 7 Plus'
  • 42. Sample App - Jenkins
  • 43. Sample App - Jenkins
  • 44. Sample App - Jenkins