@@ -26,23 +26,36 @@ class TZStackViewTestCase: XCTestCase {
2626
2727 override func setUp( ) {
2828 super. setUp ( )
29+ recreateStackViews ( )
30+ }
31+
32+ override func tearDown( ) {
33+ super. tearDown ( )
34+ }
35+
36+ func recreateStackViews( ) {
37+ // clean old views otherwise some old spacer views and constraints are left
38+ if uiStackView != nil {
39+ uiStackView. removeFromSuperview ( )
40+ }
41+
42+ if tzStackView != nil {
43+ tzStackView. removeFromSuperview ( )
44+ }
45+
2946 // Create stack views with same views
3047 uiStackView = UIStackView ( arrangedSubviews: createTestViews ( ) )
3148 uiStackView. translatesAutoresizingMaskIntoConstraints = false
3249 tzStackView = TZStackView ( arrangedSubviews: createTestViews ( ) )
3350 tzStackView. translatesAutoresizingMaskIntoConstraints = false
34-
51+
3552 let window = UIApplication . sharedApplication ( ) . windows [ 0 ]
3653 window. addSubview ( uiStackView)
3754 window. addSubview ( tzStackView)
38-
55+
3956 configureStackViews ( uiStackView, tzStackView)
4057 }
4158
42- override func tearDown( ) {
43- super. tearDown ( )
44- }
45-
4659 func logAllConstraints( ) {
4760 print ( " ================= UISTACKVIEW ( \( uiStackView. constraints. count) ) ================= " )
4861 print ( " subviews: \( uiStackView. subviews) " )
@@ -74,7 +87,9 @@ class TZStackViewTestCase: XCTestCase {
7487
7588 func verifyConstraints( log log: Bool = false ) {
7689 // Force constraints to be created
90+ uiStackView. updateConstraintsIfNeeded ( )
7791 uiStackView. layoutIfNeeded ( )
92+ tzStackView. updateConstraintsIfNeeded ( )
7893 tzStackView. layoutIfNeeded ( )
7994
8095 if log {
0 commit comments