Thursday, December 1, 2022
HomeIOS Developmentios - Write Unit Assessments to validate WKWebView load request

ios – Write Unit Assessments to validate WKWebView load request


I’ve a WKWebView to hundreds a primary url request.

guard let myUrl = URL(string: "https://www.myurl") else { return }
        let request = URLRequest(url: myUrl)

        webView?.load(request)

Now I need to write a unit take a look at to confirm webview appropriately load the request. I’ve adopted this method https://stackoverflow.com/a/63827560/627667 and created a mock navigation motion.

func test_AllowsCorrectURL() {
        let motion = MockNavigationAction()
        motion.mockedRequest = URLRequest(url: URL(string: "https://www.myurl")!)
        let allowExpectation = expectation(description: "Permits motion")
        viewController.webView(WKWebView(), decidePolicyFor: motion) { coverage in
            XCTAssertEqual(coverage, .permit)
            allowExpectation.fulfill()
        }
        waitForExpectations(timeout: 1.0)
    }

Nonetheless on this line viewController.webView(WKWebView(), decidePolicyFor: motion) I get under error.

Can't name worth of non-function kind 'WKWebView?'

Swift model 5. The way to eliminate this error? Your solutions extremely appreciated.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments