mardi 26 novembre 2019

Testing using Quick iOS: fail function isn't executing and it goes to crash

I am creating a huge test using Quick testing framework for iOS. Some tasks are asynchronous so I am calling waitUntil function with set timeout.

waitUntil(timeout: TimeInterval(self.timeout)) { done in
        // something to do
        done()
}

Sometimes test goes wrong which it caused the field wasn't set. However is always executed code which checked if field is set, so it should execute fail function when field isn't set and end of test without crash

func getField() -> Field {
    let field = blm?.su.first

    if field == nil {
        fail("No field")
    }
    return field!
} 

But I don't know what is problem that code above isn't cancelled when field is checked as nil, and during return statement - fatal unwrapping and app crash

Please help me, what is wrong here

Aucun commentaire:

Enregistrer un commentaire