I have a button click that disables the animation, and after the animation finishes, the label text changes. I would like to write a test that checks that when you click a button, the text of the label text changes correctly.
The implementation of the IBAction button will use [UIView animateWithDuration:animations:completion:]. I obviously do not want my unit test to actually wait 0.5 seconds to complete the animation.
I was thinking of a mocking UIView, but it seems strange to introduce a UIView into a view controller dependency. Also, the mocking framework I'm using (OCMockito) doesn't seem to work with mocking class methods.
I also thought of a swizzling method or writing a testing category for UIViewand using an implementation that does nothing but call a block animations:, followed by a block completion:. It seems a little broken to me; I am worried that overriding the implementation of a class method in a UIView may have unintended consequences in the future.
Being new to TDD, I'm not sure what the best practice is here. Is this one of those code snippets that should be considered "smoothing the UI" and therefore acceptable to leave unchecked? Or is there an even more obvious way to test this that I am missing?
source
share