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:

  1. the button has title of "start"
  2. 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

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -