SlideShare a Scribd company logo
UNIT TESTS
IOS
CAN WE START
TESTING TODAY?
ENVIRONMENT
CMD + ALT + ENTER
ALT + CLICK
iOS unit tests
iOS unit tests
iOS unit tests
ARRANGE
ACT
ASSERT
WHAT TO TEST?
iOS unit tests
iOS unit tests
iOS unit tests
iOS unit tests
iOS unit tests
DEPENDENCY
INJECTION
iOS unit tests
PROTOCOLS
+
EXTENSIONS
iOS unit tests
iOS unit tests
iOS unit tests
iOS unit tests
GLOBALS
iOS unit tests
iOS unit tests
iOS unit tests
iOS unit tests
iOS unit tests
iOS unit tests
iOS unit tests
TRICKS AND
GOTCHAS
• call view property to setup UIViewController’s outlets 

The getter first invokes [self loadView] if the view hasn't been set
yet. Subclasses must call super if they override the setter or getter.
• Use factories to help you arranging your test
• Prefix a test with “x” to disable it. (Use with moderation)
• Make sure your UIViewController is on window’s hierarchy before
presenting or pushing another one with it. (If you stub UIKit, you
don’t need this :P )
• Create an AppDelegate for tests
• Check Gather coverage data
• Use Expectations to test asynchronous code
GOOD PRACTICES
• TDD
• RSpec with Quick and Nimble
REFERENCES
• Writing tests in iOS apps: https://medium.com/compileswift/writing-tests-in-ios-
apps-79962e9dfd87
• iOS Unit Testing Like a Boss: https://www.youtube.com/watch?v=S5MvykD3yiE
• The Magic Tricks of Testing: https://www.youtube.com/watch?v=URSWYvyc42M
• The Two Sides of Writing Testable Code: https://news.realm.io/news/try-swift-
brandon-williams-writing-testable-code/?utm_source=ios-
list&utm_medium=email
• How to Easily Switch Your App Delegate for Testing: http://qualitycoding.org/
app-delegate-for-tests/
• Testing callbacks in Swift with XCTest: http://www.mokacoding.com/blog/
testing-callbacks-in-swift-with-xctest/
THANK YOU

😘

More Related Content

PDF
quality @angieslist
PDF
How to push a react js application in production and sleep better
PPTX
Test management struggles and challenges in SDLC
PDF
Testing Without Assertions by Ian Feather
PDF
AWS Well-Architected: Build Better Architecture, Better Business
PDF
Merge hells - Feature Toggles to the rescue
PDF
Instances Behind the Scene: What happen when you click on «create a new insta...
PDF
Swift testing ftw
quality @angieslist
How to push a react js application in production and sleep better
Test management struggles and challenges in SDLC
Testing Without Assertions by Ian Feather
AWS Well-Architected: Build Better Architecture, Better Business
Merge hells - Feature Toggles to the rescue
Instances Behind the Scene: What happen when you click on «create a new insta...
Swift testing ftw

Similar to iOS unit tests (20)

PDF
Automated Testing on iOS
PDF
A Comprehensive Guide to Efficiently Writing and Implementing iOS Unit Tests.pdf
PDF
Unit testing in xcode 8 with swift
PDF
Testing iOS applications
PPT
Nguyenvandungb seminar
PDF
Unit Tesing in iOS
PDF
Unit Testing: Special Cases
PPTX
Getting Started with XCTest and XCUITest for iOS App Testing
PPS
Unit testing_pps
PDF
XCTest_ A Complete Comprehensive Guide.pdf
PDF
Testing the waters of iOS
PDF
The Cowardly Test-o-Phobe's Guide To Testing
PDF
Understanding XCUITest Framework Your Guide to Efficient iOS Testing.pdf
PPT
Unit Testing in iOS
PDF
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
PDF
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
PDF
Unit tests in node.js
PDF
Automated Xcode 7 UI Testing
PDF
Unit testing (Exploring the other side as a tester)
PDF
Beginning iOS unit testing
Automated Testing on iOS
A Comprehensive Guide to Efficiently Writing and Implementing iOS Unit Tests.pdf
Unit testing in xcode 8 with swift
Testing iOS applications
Nguyenvandungb seminar
Unit Tesing in iOS
Unit Testing: Special Cases
Getting Started with XCTest and XCUITest for iOS App Testing
Unit testing_pps
XCTest_ A Complete Comprehensive Guide.pdf
Testing the waters of iOS
The Cowardly Test-o-Phobe's Guide To Testing
Understanding XCUITest Framework Your Guide to Efficient iOS Testing.pdf
Unit Testing in iOS
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Unit tests in node.js
Automated Xcode 7 UI Testing
Unit testing (Exploring the other side as a tester)
Beginning iOS unit testing
Ad

Recently uploaded (6)

DOC
Camb毕业证学历认证,格罗斯泰斯特主教大学毕业证仿冒文凭毕业证
DOC
证书学历UoA毕业证,澳大利亚中汇学院毕业证国外大学毕业证
PPTX
ASMS Telecommunication company Profile
PDF
heheheueueyeyeyegehehehhehshMedia-Literacy.pdf
PDF
Lesson 13- HEREDITY _ pedSAWEREGFVCXZDSASEWFigree.pdf
PDF
6-UseCfgfhgfhgfhgfhgfhfhhaseActivity.pdf
Camb毕业证学历认证,格罗斯泰斯特主教大学毕业证仿冒文凭毕业证
证书学历UoA毕业证,澳大利亚中汇学院毕业证国外大学毕业证
ASMS Telecommunication company Profile
heheheueueyeyeyegehehehhehshMedia-Literacy.pdf
Lesson 13- HEREDITY _ pedSAWEREGFVCXZDSASEWFigree.pdf
6-UseCfgfhgfhgfhgfhgfhfhhaseActivity.pdf
Ad

iOS unit tests

  • 4. CMD + ALT + ENTER ALT + CLICK
  • 31. • call view property to setup UIViewController’s outlets 
 The getter first invokes [self loadView] if the view hasn't been set yet. Subclasses must call super if they override the setter or getter. • Use factories to help you arranging your test • Prefix a test with “x” to disable it. (Use with moderation) • Make sure your UIViewController is on window’s hierarchy before presenting or pushing another one with it. (If you stub UIKit, you don’t need this :P ) • Create an AppDelegate for tests • Check Gather coverage data • Use Expectations to test asynchronous code
  • 32. GOOD PRACTICES • TDD • RSpec with Quick and Nimble
  • 33. REFERENCES • Writing tests in iOS apps: https://medium.com/compileswift/writing-tests-in-ios- apps-79962e9dfd87 • iOS Unit Testing Like a Boss: https://www.youtube.com/watch?v=S5MvykD3yiE • The Magic Tricks of Testing: https://www.youtube.com/watch?v=URSWYvyc42M • The Two Sides of Writing Testable Code: https://news.realm.io/news/try-swift- brandon-williams-writing-testable-code/?utm_source=ios- list&utm_medium=email • How to Easily Switch Your App Delegate for Testing: http://qualitycoding.org/ app-delegate-for-tests/ • Testing callbacks in Swift with XCTest: http://www.mokacoding.com/blog/ testing-callbacks-in-swift-with-xctest/