I'm using Quick library for unit testing.
I'm trying to test ViewController
, view of which is made as XIB
.
I connected view with file owner, and view component with view controller.
And for viewDidLoad
test, I accessed view to trigger viewDidLoad()
.
Here's my code.
override func spec() {
super.spec()
var sut: QuestionViewController!
describe("viewDidLoad") {
afterEach {
sut = nil
}
beforeEach {
sut = QuestionViewController(question: "Q1")
_ = sut.view
}
it("renders question header text") {
expect(sut.headerLabel.text).toEventually(equal("Q1"))
}
}
}
But when run the test, nothing happens with just 'test fail'. I setup break point inside spec(), but it just pass through.(nothing happens)
After removing xib file and make UI components programmatically, the test finally succeeded.
How to test ViewController
(viewDidLoad etc.) that contains xib file when using Quick
?