swift - iOS: Unit Testing UIViewController Components with XCTest -
i implementing unit test on functionality of ios uibutton in view controller in swift. expected functionality of button followed:
- the button has title of "start"
- after button pressed, title changes "pause"
in short, test button's title changed "start" "pause" after button has been clicked.
because system needs bit of time before change takes place , rendered on screen, need poll short amount of time check current title of button until either button title changes or allotted time runs out.
normally, use quick/nimble framework unit testing , use expect(...).toeventually(...)
function test kind of polling. however, team insists use xctest framework sake of consistency, have find elegant way implement test xctest.
do have suggestions implementation xctest framework?
a solution can come using nstimer
triggers condition check every small interval until designated time runs out, , use xctestexpectation
, waitforexpectationswithtimeout
in order wait completion. (see more xctestexpectation here)
are there better ways implement unit test?
Comments
Post a Comment