Skip to content

Commit

Permalink
Refactor test, replace 70 test functions with just one
Browse files Browse the repository at this point in the history
  • Loading branch information
CosynPa committed Nov 8, 2015
1 parent ff80e74 commit b0135a8
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 986 deletions.
27 changes: 21 additions & 6 deletions TZStackViewTests/TZStackViewTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,36 @@ class TZStackViewTestCase: XCTestCase {

override func setUp() {
super.setUp()
recreateStackViews()
}

override func tearDown() {
super.tearDown()
}

func recreateStackViews() {
// clean old views otherwise some old spacer views and constraints are left
if uiStackView != nil {
uiStackView.removeFromSuperview()
}

if tzStackView != nil {
tzStackView.removeFromSuperview()
}

// Create stack views with same views
uiStackView = UIStackView(arrangedSubviews: createTestViews())
uiStackView.translatesAutoresizingMaskIntoConstraints = false
tzStackView = TZStackView(arrangedSubviews: createTestViews())
tzStackView.translatesAutoresizingMaskIntoConstraints = false

let window = UIApplication.sharedApplication().windows[0]
window.addSubview(uiStackView)
window.addSubview(tzStackView)

configureStackViews(uiStackView, tzStackView)
}

override func tearDown() {
super.tearDown()
}

func logAllConstraints() {
print("================= UISTACKVIEW (\(uiStackView.constraints.count)) =================")
print("subviews: \(uiStackView.subviews)")
Expand Down Expand Up @@ -74,7 +87,9 @@ class TZStackViewTestCase: XCTestCase {

func verifyConstraints(log log: Bool = false) {
// Force constraints to be created
uiStackView.updateConstraintsIfNeeded()
uiStackView.layoutIfNeeded()
tzStackView.updateConstraintsIfNeeded()
tzStackView.layoutIfNeeded()

if log {
Expand Down

0 comments on commit b0135a8

Please sign in to comment.