Unit Testing Swift

[Solved] Unit Testing Swift | Swift - Code Explorer | yomemimo.com
Question : unit testing swift

Answered by : fancy-flatworm-7imy9ovj7bjb

// Correct result, tests succeeds func testAdditionCorrectResult() { let firstNumber = 5 let secNumber = 9 let result = firstNumber + secNumber // Check if the result of the addition is the expected one XCTAssertEqual(result, 14, "Result of addition is wrong!") }
// Wrong result, tests fails func testAdditionWrongResult() { let firstNumber = 5 let secNumber = 9 let result = firstNumber + secNumber // Check if the result of the addition is the expected one XCTAssertEqual(result, 15, "Result of addition is wrong!") }

Source : https://www.raywenderlich.com/21020457-ios-unit-testing-and-ui-testing-tutorial | Last Update : Thu, 16 Jun 22

Answers related to unit testing swift

Code Explorer Popular Question For Swift