How do I mock network requests in Xcode UI tests while the tests are running?

前端 未结 3 605
天命终不由人
天命终不由人 2020-12-11 08:18

We\'ve got a suite of UI tests for our app written using KIF which I\'d like to convert to use the new Xcode UI test framework.

The app is a client of a Rest AI whos

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-11 08:29

    We've developed an embedded HTTP server in pure Swift, you can run the HTTP server with simple mock response handler in your test case, then pass the URL to the target app via environment variable like API_BASE_URL. I wrote an article about how to do it

    Embedded web server for iOS UI testing

    Basically there are two libraries, one is Embassy, it's the simple async HTTP server. Another one is Ambassador, a simple web framework for mocking API endpoints.

提交回复
热议问题