Closed michaelknoch closed 5 years ago
Also tests are broken for a very interesting reason. (ButtonContentAlignmentTests.swift)
It makes sense that this is currently breaking here because UIApplication never inits the main window when running tests. It's very interesting that iOS seems to handle this case. Maybe UIScreen.main should always return a screen?
@michaelknoch I have made provisions for this in UIScreen.swift but not yet updated the tests.
It’s possible to init a dummy screen in the tests (there is an internal initialiser in that file that we can use with @testable import
). I think this is better than the old solution
So we always have to manually init a UIScreen as soon as we are writing tests for UIView or something that depends on it? Sounds like an easy fix but also sounds kind of verbose and iOS seems to handle it different because the buttons tests are passing on iOS. @ephemer
@michaelknoch there are “global” setup / tear downs. I’d init the screen in there in the UIKit Test target. In practice it should be clean and also explicit, which is better than the kind of random implicit behaviour we used to have
Like the solution! Didn't know that we have this global testing hooks, very useful. I allowed myself to commit some changes @ephemer
Tests are still failing due to some font tests, its working on my machine :ok_woman:
Type of change:
Motivation (current vs expected behavior)
tbd
Please check if the PR fulfills these requirements