Small presentation I've made for Wire team about testing process in iOS Sync Engine Team. You can read more in depth here - http://www.objc.io/issues/15-testing/xctest/
6. • 3356 tests on OSX
• 3415 tests on iOS (+ apns tests)
Overall tests stats
7. • 3356 tests on OSX
• 3415 tests on iOS (+ apns tests)
• ~ 7.5 minutes to build and run all the tests on
one platform (build ~ 40s, tests ~ 7 min)
Overall tests stats
8. • 3356 tests on OSX
• 3415 tests on iOS (+ apns tests)
• ~ 7.5 minutes to build and run all the tests on
one platform (build ~ 40s, tests ~ 7 min)
Overall tests stats
16. What we DON’T do:
• test against http:// (real backend)
• test using http requests stubs (like
OHHTTPStubs)
Our test strategies
17. What we DON’T do:
• test against http:// (real backend)
• test using http requests stubs (like
OHHTTPStubs)
Why?
• Stubs are not that flexible.
Our test strategies
18. What we DON’T do:
• test against http:// (real backend)
• test using http requests stubs (like
OHHTTPStubs)
Why?
• Stubs are not that flexible.
• It’s still slow.
Our test strategies
19. What we really do:
• Test against fake backend
Our test strategies
20. What we really do:
• Test against fake backend
Advantages
• Fast
• Flexible
• Independent
• Testable
Our test strategies
21. What we really do:
• Test against fake backend
Advantages
• Fast
• Flexible
• Independent
• Testable
Disadvantages
• Need to write (and
test!) code
• Need to be in sync
with real backend
(can be improved)
Our test strategies
27. WTF is THAT?
ZMTransportSession - is a delegate of a delegate
of NSURLSession
• Sends http requests to scheduler
MockTransportSession
28. WTF is THAT?
ZMTransportSession - is a delegate of a delegate
of NSURLSession
• Sends http requests to scheduler
• Handles authentication
MockTransportSession
29. WTF is THAT?
ZMTransportSession - is a delegate of a delegate
of NSURLSession
• Sends http requests to scheduler
• Handles authentication
• Opens/closes web socket connection
MockTransportSession
33. WTF is THAT?
• Make fake requests
• Records requests and responds to them
MockTransportSession
34. WTF is THAT?
• Make fake requests
• Records requests and responds to them
• Manages internal database
MockTransportSession
35. WTF is THAT?
• Make fake requests
• Records requests and responds to them
• Manages internal database
• Can simulate remote changes.
MockTransportSession
36. WTF is THAT?
• Make fake requests
• Records requests and responds to them
• Manages internal database
• Can simulate remote changes.
• Can send push channel (web socket) events
MockTransportSession
37. • Before each test we insert objects in internal
database (in memory)
MockTransportSession
38. • Before each test we insert objects in internal
database (in memory)
• Test code make request using MockTransportSession
MockTransportSession
39. • Before each test we insert objects in internal
database (in memory)
• Test code make request using MockTransportSession
• It records and process incoming request (filtering by
path and lots of ifs)
MockTransportSession
40. • Before each test we insert objects in internal
database (in memory)
• Test code make request using MockTransportSession
• It records and process incoming request (filtering by
path and lots of ifs)
• Performs some CRUD action on database
depending on request (add message, create
conversation, fetch conversation)
MockTransportSession
41. • Before each test we insert objects in internal
database (in memory)
• Test code make request using MockTransportSession
• It records and process incoming request (filtering by
path and lots of ifs)
• Performs some CRUD action on database
depending on request (add message, create
conversation, fetch conversation)
• Creates and sends response. Optionally can
delegate it to other object (i.e. test case).
MockTransportSession
45. • Finished feature - run all the tests
• Create pull request
• Review, merge
Workflow
46. • Finished feature - run all the tests
• Create pull request
• Review, merge
• Release script runs all tests locally
Workflow
47. • Finished feature - run all the tests
• Create pull request
• Review, merge
• Release script runs all tests locally
• Pushes to remote branches (master/develop)
Workflow
48. • Finished feature - run all the tests
• Create pull request
• Review, merge
• Release script runs all tests locally
• Pushes to remote branches (master/develop)
• Xcode bots make integration on each push to master/
develop
Workflow
49. • Finished feature - run all the tests
• Create pull request
• Review, merge
• Release script runs all tests locally
• Pushes to remote branches (master/develop)
• Xcode bots make integration on each push to master/
develop
• Each bot for each platform runs all the tests
Workflow
50. • Finished feature - run all the tests
• Create pull request
• Review, merge
• Release script runs all tests locally
• Pushes to remote branches (master/develop)
• Xcode bots make integration on each push to master/
develop
• Each bot for each platform runs all the tests
• Bots archive and upload binary to the cloud
Workflow
59. • Split to smaller frameworks - to improve run time
Future plans
60. • Split to smaller frameworks - to improve run time
• Setup Buildasaur - to run tests on Github pull
requests
Future plans
61. • Split to smaller frameworks - to improve run time
• Setup Buildasaur - to run tests on Github pull
requests
• Record/replay tests for MockTransportSession -
to keep it in sync
Future plans