Post

Replies

Boosts

Views

Activity

Reply to How to test WKWebview
I don't know all the technicalities behind WKNavigation implementation, but it appears that as soon as the control exits the current scope, WKNavigation object gets deallocated automatically -- as if it's set to auto-release itself, and that's why you get the crash. The method signature expects to get a non-nil navigation object (it's explicitly unwrapped). You need to declare your instance of WKNavigation in a scope that out lives the scope of the test function itself. This will work, though: class MyTestCase: XCTestCase { 	let navigation = WKNavigation() 		func testDelegate() { 			// some assertions 			delegate.webView(webView, didFail: navigation, withError: error) 			// some assertions 		} }
Jun ’20