+ All Categories
Home > Technology > Designing for testability - Anton Shchukin - NSSpain2016

Designing for testability - Anton Shchukin - NSSpain2016

Date post: 09-Jan-2017
Category:
Upload: badoo
View: 258 times
Download: 2 times
Share this document with a friend
40
Design for Testability Anton Schukin, iOS Developer twitter: @antonpalich
Transcript

Design for TestabilityAnton Schukin, iOS Developer

twitter: @antonpalich

My History2013 - 2015

2015 - Now

My History2013 - 2015

2015 - Now

320M+ registered users 190 countries 46 languages 50M+ downloads (iOS)

Overview1. Unit Testing in Badoo 2. F.I.R.S.T 3. Unit Testing in practice

11 developers

iOS Team

11 developers, weekly releases: ~ 300 commits ~ 1 000 files changed

iOS Team

11 developers, weekly releases: ~ 300 commits ~ 1 000 files changed ~ 50 000 insertions ~ 63 000 deletions (Legacy code removals)

iOS Team

New Features

Changes

New Features Bug fixing

Changes

New Features Bug fixing Technical debts

Changes

Code Coverage

20

25

30

35

40

Sep Oct Nov Dec Jan Feb Mar Apr May June July Aug Sep

from 23.47% to 36.47% (70675 / 193726 lines)

Find problem earlier

Unit Testing - WHY?

Find problem earlier Regression tests for changes

Unit Testing - WHY?

Find problem earlier Regression tests for changes Live documentation

Unit Testing - WHY?

Unit Testing - WHAT?

Unit Testing - WHAT?

State Interaction with dependencies

Unit Testing - WHAT?

State Interaction with dependencies

MVP MVCMVVM VIPER

F.I.R.S.T*

• Fast

• Independent

• Repeatable

• Self-validating

• Timely

*Robert C. Martin «Clean Code»

Fast

1s 100ms 10ms

100 tests 1m 40s 10s 1s

1000 tests 16m 40s 1m 40s 10s

4000 tests 1h 6m 40s 6m 40s 40s

Fast

1s 100ms 10ms

100 tests 1m 40s 10s 1s

1000 tests 16m 40s 1m 40s 10s

4000 tests 1h 6m 40s 6m 40s 40s

Fast

3877 tests in 79.66s (~49ms per test)*

* MacBook Pro Retina (Early 2013), 2.7 GHz i7, 16GB 1600 MHz

Independent

T1

Sandbox

T2 T3 T4

+[NSUserDefaults standardUserDefaults]

Independent

T1

Sandbox

Mock

T2

Sandbox

Mock

T3

Sandbox

Mock

T4

Sandbox

Mock

Repeatable

T1

Dev 1

Result

T1

Dev 2

Result

T1

CI 1

Result

T1

CI 2

Result== == ==

Self-validating

PASSED OR FAILED

Timely

Timely

Dev PolishingTest after code

for code coverage

Timely

Dev Polishing

Dev PolishingTest after code

for code coverage

Test after code for value

Timely

Dev

Dev Polishing

Dev PolishingTest after code

for code coverage

Test after code for value

TDD

New Feature

Download user photos

New Feature

Download user photos Store compressed and original photos

New Feature

Download user photos Store compressed and original photos Do it no more than every four hours

New Feature

Download user photos Store compressed and original photos Do it no more than every four hours Do it when your app becomes active

Code Example

https://github.com/AntonPalich/NSSpain16Example

Conclusion

Think about interfaces first

Conclusion

Think about interfaces first Unit tests is your friend

Conclusion

Think about interfaces first Unit tests is your friend TDD saves developer time

Conclusion

Think about interfaces first Unit tests is your friend TDD saves developer time TAD (Test after development) also fine

Thank you! We’re hiring

twitter: @BadooTech github.com/Badoo


Recommended