TDD using Xcode Playgrounds

TDD using Xcode Playgrounds

CodeMobile 2017 lightning talk

B726bf6980ae838cb19d2f0ee2cec9ef?s=128

Paul Ardeleanu

April 19, 2017
Tweet

Transcript

  1. TDD using Xcode Playgrounds  Paul Ardeleanu @pardel

  2. TDD using Xcode Playgrounds - CodeMobile, April 2017 @pardel Test

    Driven Development 
  3. TDD using Xcode Playgrounds - CodeMobile, April 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
  4. TDD using Xcode Playgrounds - CodeMobile, April 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
  5. TDD using Xcode Playgrounds - CodeMobile, April 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
  6. TDD using Xcode Playgrounds - CodeMobile, April 2017 @pardel Testing

    in iOS 
  7. TDD using Xcode Playgrounds - CodeMobile, April 2017  @pardel

    Testing in iOS XCTest - Xcode 5
  8. TDD using Xcode Playgrounds - CodeMobile, April 2017  @pardel

    Testing in iOS XCTest - Xcode 5
  9. TDD using Xcode Playgrounds - CodeMobile, April 2017 @pardel Playgrounds

  10. import XCTest class TaskTests: XCTestCase { func testCanCreateATask() { }

    }
  11. import XCTest class TaskTests: XCTestCase { func testCanCreateATask() { XCTAssertNotNil(Task())

    } }
  12. import XCTest class Task { } class TaskTests: XCTestCase {

    func testCanCreateATask() { XCTAssertNotNil(Task()) } }
  13. import XCTest class Task { } class TaskTests: XCTestCase {

    func testCanCreateATask() { XCTAssertNotNil(Task()) } } TaskTests.defaultTestSuite().run()
  14. import XCTest class Task { ... } class TaskTests: XCTestCase

    { ... } TaskTests.defaultTestSuite().run() class TaskManager { ... } class TaskManagerTests: XCTestCase { ... } TaskManagerTests.defaultTestSuite().run() Test Suite 'TaskTests' started at 2017-04-19 11:00:38.804 Test Case '-[__lldb_expr_5.TaskTests testTaskHasAName]' started. Test Case '-[__lldb_expr_5.TaskTests testTaskHasAName]' passed (0.041 seconds). Test Case '-[__lldb_expr_5.TaskTests testTaskMustHaveAName]' started. Test Case '-[__lldb_expr_5.TaskTests testTaskMustHaveAName]' passed (0.005 seconds). Test Suite 'TaskTests' passed at 2017-04-19 11:00:38.851. Executed 2 tests, with 0 failures (0 unexpected) in 0.046 (0.048) seconds Test Suite 'TaskManagerTests' started at 2017-04-19 11:00:38.851 Test Case '-[__lldb_expr_5.TaskManagerTests testCanAddTask]' started. Test Case '-[__lldb_expr_5.TaskManagerTests testCanAddTask]' passed (0.010 seconds). Test Case '-[__lldb_expr_5.TaskManagerTests testHasTasks]' started. Test Case '-[__lldb_expr_5.TaskManagerTests testHasTasks]' passed (0.001 seconds). Test Suite 'TaskManagerTests' passed at 2017-04-19 11:00:38.862. Executed 2 tests, with 0 failures (0 unexpected) in 0.011 (0.011) seconds
  15. None
  16. TDD using Xcode Playgrounds - CodeMobile, April 2017 @pardel Unit

    tests 
  17. TDD using Xcode Playgrounds - CodeMobile, April 2017 @pardel

  18. TDD using Xcode Playgrounds - CodeMobile, April 2017 @pardel 

    m.pardel.net
  19. TDD using Xcode Playgrounds - CodeMobile, April 2017 @pardel leanpub.com/test-gtfo

  20. TDD using Xcode Playgrounds - CodeMobile, April 2017 @pardel

  21. TDD using Xcode Playgrounds - CodeMobile, April 2017 @pardel Thank

    you! paul@lupo.uk