How to implement unit test for a fatalError
code path in Swift?
For example, I've the following swift code
func divide(x: Float, by y: Float) -> Float {
guard y != 0 else {
fatalError("Zero division")
}
return x / y
}
I want to unit test the case when y = 0.
Note, I want to use fatalError not any other assertion function.
Aucun commentaire:
Enregistrer un commentaire