Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TDD in Xcode Playgrounds

TDD in Xcode Playgrounds

Apart from being an awesome code prototyping tool, the Xcode Playgrounds can also be used for Test Driven Development.

In this short talk, Paul will show you how to unit test your code using Playgrounds, how to make use 3rd party libraries and generally how to avoid the excuse of testing being too hard :)

Paul Ardeleanu

March 30, 2017
Tweet

More Decks by Paul Ardeleanu

Other Decks in Programming

Transcript

  1. TDD using Xcode Playgrounds

    Paul Ardeleanu
    @pardel

    View Slide

  2. TDD using Xcode Playgrounds - London, March 2017 @pardel
    Test Driven Development

    View Slide

  3. TDD using Xcode Playgrounds - London, March 2017

    @pardel
    TDD
    according to Wikipedia
    “Test-driven development (TDD) is a software development process
    that relies on the repetition of a very short development cycle:
    requirements are turned into very specific test cases, then the
    software is improved to pass the new tests, only. This is opposed
    to software development that allows software to be added that is not
    proven to meet requirements.”
    https://en.wikipedia.org/wiki/Test-driven_development

    View Slide

  4. TDD using Xcode Playgrounds - London, March 2017 @pardel
    Test Driven Development

    View Slide

  5. TDD using Xcode Playgrounds - London, March 2017

    @pardel
    Pick a feature to implement
    making sure it’s a small enough unit.
    FEATURE
    Change any of the existing code
    making sure ALL tests are passing.
    REFACTOR
    Write a failing test.
    Stop as soon as you get a failure.
    RED
    Write code to pass the test.
    Write as little code as possible.
    GREEN
    L (
    )
    TDD lifecycle
    Feature, Red, Green, Refactor

    View Slide

  6. TDD using Xcode Playgrounds - London, March 2017

    @pardel
    New
    feature
    create test
    enough code to
    make it pass
    successful
    test execution
    No
    anything to
    refactor
    Yes
    Yes
    refactoring
    No
    Ya Ain’t Gonna Need It
    TDD lifecycle
    Feature, Red, Green, Refactor

    View Slide

  7. TDD using Xcode Playgrounds - London, March 2017 @pardel
    Testing in iOS

    View Slide

  8. TDD using Xcode Playgrounds - London, March 2017

    @pardel
    Testing in iOS
    XCTest - Xcode 5

    View Slide

  9. TDD using Xcode Playgrounds - London, March 2017

    @pardel
    Testing in iOS
    XCTest - Xcode 5

    View Slide

  10. TDD using Xcode Playgrounds - London, March 2017 @pardel
    Demo

    View Slide

  11. TDD using Xcode Playgrounds - London, March 2017 @pardel
    Unit tests

    View Slide

  12. TDD using Xcode Playgrounds - London, March 2017 @pardel

    m.pardel.net

    View Slide

  13. TDD using Xcode Playgrounds - London, March 2017 @pardel
    leanpub.com/test-gtfo

    View Slide

  14. TDD using Xcode Playgrounds - London, March 2017 @pardel

    View Slide

  15. TDD using Xcode Playgrounds - London, March 2017

    @pardel
    TDD Workshop

    View Slide

  16. TDD using Xcode Playgrounds - London, March 2017 @pardel
    Thank you!
    [email protected]

    View Slide