Esiste qualche equivalente per verificare l'esistenza di eccezioni di lancio nella lingua swift Test unitari?Test unità Swift con XCTAssertThrows analogico
Per esempio ho una classe:
class Square : NSObject{
let sideLength: Int
init(sideLength: Int) {
assert(sideLength >= 0, "Wrong initialization of Square class with below zero side length")
self.sideLength = sideLength
super.init()
}
}
e Test per verificare il lavoro. Nell'obiettivo C posso scrivere un metodo di prova come questo:
- (void)testInitializationWithWrongSideLengthThrowsExceptions{
XCTAssertThrows([[Shape alloc] initWithSideLength: -50], "Should throw exceptions on wrong side values initialisations");
}
Che cos'è Swift uguale tecnica?
@Vignesh Kumar: Per favore basta smettere del tutto retagging domande Swift. Non stai aiutando. Affatto. – BoltClock