unit testing in swift 2 - the before & after story

23
Unit Testing in Swift 2: The Before & After Story Jorge D. Ortiz-Fuentes @jdortiz #Swift2Testing

Upload: jorge-ortiz

Post on 15-Apr-2017

632 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Unit testing in swift 2 - The before & after story

Unit Testing in Swift 2: The Before & After

StoryJorge D. Ortiz-Fuentes

@jdortiz

#Swift2Testing

Page 2: Unit testing in swift 2 - The before & after story

A Canonical Examples

production

#Swift2Testing

Page 3: Unit testing in swift 2 - The before & after story

#Swift2Testing

Agenda

★Using testable

★Testing error handling

★Measuring test coverage

Page 4: Unit testing in swift 2 - The before & after story

#Swift2Testing

Agenda

★Using testable

★Testing error handling

★Measuring test coverage

Page 5: Unit testing in swift 2 - The before & after story

Using testable

Page 6: Unit testing in swift 2 - The before & after story

Swift Modules

Test Bundle = Module

App / Framework = Module

Internal x

Testable

Page 7: Unit testing in swift 2 - The before & after story

https://github.com/jdortiz/EvilTalentSwift2

Demo

Page 8: Unit testing in swift 2 - The before & after story

BeforeMake everything public

or Include the classes in

testing target

Detestable

Page 9: Unit testing in swift 2 - The before & after story

After@testable import Module

provides access to everything internal

Testable

Page 10: Unit testing in swift 2 - The before & after story

#Swift2Testing

Agenda

★Using testable

★Testing error handling

★Measuring test coverage

Page 11: Unit testing in swift 2 - The before & after story

Testing error handling

Page 12: Unit testing in swift 2 - The before & after story

Always Look at the Bright Side

Don’t

Page 13: Unit testing in swift 2 - The before & after story

https://github.com/jdortiz/EvilTalentSwift2

Demo

Page 14: Unit testing in swift 2 - The before & after story

BeforeDeal with pointers to

references and put the data in there in order to

mock the behavior

Page 15: Unit testing in swift 2 - The before & after story

AfterJust implement a test for the case when it fails and

mock the failure

Page 16: Unit testing in swift 2 - The before & after story

#Swift2Testing

Agenda

★Using testable

★Testing error handling

★Measuring test coverage

Page 17: Unit testing in swift 2 - The before & after story

Test coverage

Page 18: Unit testing in swift 2 - The before & after story

The importance of Unit Testing

Page 19: Unit testing in swift 2 - The before & after story

https://github.com/jdortiz/EvilTalentSwift2

Demo

Page 20: Unit testing in swift 2 - The before & after story

BeforeNo idea about how much code is actually tested

Page 21: Unit testing in swift 2 - The before & after story

AfterPer method/class coverage information

Page 22: Unit testing in swift 2 - The before & after story

Thank you!

Page 23: Unit testing in swift 2 - The before & after story

@jdortiz #Swift2Testing