my test keeps crashing, it’s an assertionFailure in onChange. But that’s expected. the onChange method should receive a snapshot which conforms to the protocol. Is there a way to keep this test while still keeping the assertionFailure in onChange, which triggers in a guard statement if the it doesnt conform to the protocol?
func testOnChangeWithInvalidValueShouldNotUpdateSnapshot() {
let listener = SomeListenerFake()
let expectation = XCTestExpectation(description: "Snapshot updated and listener notified")
expectation.isInverted = true
fakeListener.onUpdatedModelList = {
expectation.fulfill()
}
guard let delegate = someObject as? SomeDelegate else {
XCTFail("someObject is not a SomeDelegate")
return
}
someObject?.set(listener: listener)
delegate.onChange(withId: "invalid value")
wait(for: [expectation], timeout: 1.0)
XCTAssertNil(listener.capturedValue)
XCTAssertFalse(listener.methodCalled)
}
2