Beginner play Test-Driven Development(TDD) in swift

2 day ago i learn about TDD: Test Driven Development when i read content i think why we should have TDD process when we develop some app. I found it from 3 site below.

Two goal for doing Test-Driven Development

  • Make sure my code is in the right place
  • Make sure my logic is correct
  • I try coding abit on “Nil Test”, use XCTAssertNotNil to assert the existence of a given value.
    Let try…

    and .. my view controller

    Try try try … and don’t forget check your test in Target Membership on File inspector

    and then run test use command+u …
    WTH!!! We will see
    Oh why.. why it not pass , because myVar on view controller is Nil
    You try to uncomment this line on view controller and run test again (command+u)

    Success!! We will see

    Wow nice development process for us. You can try other XCTest Assertions on list

    • Fundamental Test : XCTAssert(expression, format…)
    • Boolean Tests : XCTAssert[False]True(expression, format…)
    • Equality Tests : XCTAssert[Not]Equal(expression1, expression2, format…)
    • Equality(Double,Float or other floating-point) Tests : XCTAssert[Not]EqualWithAccuracy(expression1, expression2, accuracy, format…)
    • Nil Tests : XCTAssert[Not]Nil(expression, format…)
    • Unconditional Failure : XCTFail(format…)

    Example project : Download
    Next time we will talk about Performance Testing and XCTestExpectation.
    K Bye .

    Thank nice image from

    Example Project : Realm with Swift 2.0
    How to make tableviewcell animation using Swift
    CLLocationManager Singleton in Swift