We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am trying to do a test for the updateCounter() Method however it keeps returning nil and crashing
func UpdateTimer() { Counter = Counter + 0.1 timeLabel.text = String(format: "%.1f", Counter) }
Here is the code I used to generate the test, and tried to use a fake UIlabel to capture the update method.
class StopWatchTests: XCTestCase { var sut:ViewController! override func setUp() { super.setUp() sut = ViewController() let testingUIlabelFrame = CGRectMake(5, 5, 100, 100) sut.timeLabel = UILabel(frame: testingUIlabelFrame) sut.timeLabel.text = "test" } override func tearDown() { super.tearDown() sut = nil } func testUpdateTimere() { //Test that counter is incremented by one sut.Counter = 10 sut.UpdateTimer() XCTAssertEqual(sut.Counter, 11) let timelabel = sut.timeLabel.text }
class StopWatchTests: XCTestCase { var sut:ViewController!
override func setUp() { super.setUp() sut = ViewController() let testingUIlabelFrame = CGRectMake(5, 5, 100, 100) sut.timeLabel = UILabel(frame: testingUIlabelFrame) sut.timeLabel.text = "test" } override func tearDown() { super.tearDown() sut = nil } func testUpdateTimere() { //Test that counter is incremented by one sut.Counter = 10 sut.UpdateTimer() XCTAssertEqual(sut.Counter, 11) let timelabel = sut.timeLabel.text }
Besides refactoring the logic to move the ui update to a different method - is there any way to make above work as is?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am trying to do a test for the updateCounter() Method however it keeps returning nil and crashing
Here is the code I used to generate the test, and tried to use a fake UIlabel to capture the update method.
Besides refactoring the logic to move the ui update to a different method - is there any way to make above work as is?
The text was updated successfully, but these errors were encountered: