Funny

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
    file-inspector

    and then run test use command+u …
    WTH!!! We will see
    not-pass-test
    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
    tdd-success

    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
    http://littlevisuals.co/

    iOS
    Standard signals in iOS application crashes
    iOS
    Swift with Firebase
    iOS
    WatchKit Apps in Objective-C
    There are currently no comments.