Tests which use tintColor are failing after 2.1.0 if an UIAlertView is active in the host app prior to test execution
nikolaykasyanov opened this issue · comments
I think this is somehow related to using keyWindow
instead of a new instance for making a snapshot (d6617c5).
@nikolaykasyanov could you add some example project? I've been using today UIAppearance and FBSnapshotTestCase and everything works well.
@Grubas7 I think I've found the culprit. It's a UIAlertView
instance which remains active after one of the unit tests. And FBSnapshotTestCase uses keyWindow
since 2.1.0, and keyWindow
in this case is some fancy subclass used by UIAlertView
(_UIAlertControllerShimPresenterWindow
) which screws tintColor
completely.
You can find sample project attached. Please use iPhone 6 iOS 8.4 simulator.
Run all tests (Cmd+U) to trigger the failure. Run TestViewTests
in isolation and it would succeed.
@nikolaykasyanov Thanks! I'll take a look at this at the weekend.
@Grubas7 thanks for looking at this
@nikolaykasyanov Sorry for late, but I checked your case.
I've been able to reproduce your scenario thanks to your sample!
I think the problem is not FBSnapshotTest by it self, but UIAlertView which make a mess in views with tintColor
.
I fixed this by disabling animation for test with UIAlertView using [UIView setAnimationsEnabled:NO];
in -setUp
. Then you could turn them back on by [UIView setAnimationsEnabled:YES];
, but personally I keep disabled this in most tests ;)
Hope this helped!
@Grubas7 thanks for you research & advice, I'll try it soon.
But I personally consider this bug as a violation of test isolation principle. It's not good when test results depend on the external global state like current application's keyWindow
.
It's not good when test results depend on the external global state like current application's
keyWindow
.
True.