与以下问题类似的问题: XCTest pass in isolation
没有有效的答案。
这些是我的tearDown
和setup
:
override func tearDown() {
window = nil
window = UIWindow()
super.tearDown()
}
override func setUp() {
super.setUp()
window = UIWindow()
let bundle = Bundle.main
let storyboard = UIStoryboard(name: "Main", bundle: bundle)
sut = storyboard.instantiateViewController(withIdentifier:
"OTPViewController") as? OTPViewController
}
//**
func testDisplayHelpLabel() {
//Given
let testText = "testText"
let attrStr = NSAttributedString(string: testText)
let attrText = NSMutableAttributedString(attributedString: attrStr)
//When
loadView()
//it changes help Label text with attributed text
sut.displayHelpLabel(attributedText: attrText)
//Then'
XCTAssertEqual(sut.helpLabel.attributedText, attrText, "both must have equal value")
}
错误: XCTAssertEqual failed - both must have equal value
有什么帮助吗?