Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

unit testing swift ui

//    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!")
    }
Comment

PREVIOUS NEXT
Code Example
Swift :: swift create a method who can return result or throw an error 
Swift :: swift scroll to tableviewcell 
Swift :: and in swif 
Swift :: swift initialize a view 
Swift :: show back button in navbar swift 
Swift :: uitableview set space between cells 
Swift :: get day difference between two dates swift 
Swift :: How to find index of list item in Swift? 
Swift :: swift convert base64 string to data 
Swift :: Swift Basic Input 
Swift :: uitableview scroll to bottom swift 
Swift :: swift uitextfield placeholder color 
Swift :: swift close view 
Swift :: swift pdf preview image 
Swift :: swift array remove 
Swift :: swift sort list true before false 
Swift :: swift set keyboard next functionality 
Swift :: how to make month format in swift 
Swift :: swift guard statement 
Swift :: swift ui view 
Swift :: swift wait until condition is true 
Swift :: Swift Add/Remove Elements From Tuple 
Swift :: Swift Join Two Strings 
Swift :: Swift Conform Class To Swift Protocol 
Swift :: Swift Optional Binding (if-let 
Swift :: swift chuck array in peases 
Swift :: Swift guard with multiple conditions 
Swift :: Swift Closed Range 
Swift :: secure password field in textfield swift 
Swift :: Swift Character 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =