How to unit test API in Xcode requiring authenticated state?

I need to check the API, which suggested that you already went through OAuth and got access_token. How to create unit tests for such an API in Xcode without having to run an OAuth username before each test?

Can I create test cases for OAuth and make sure they run first (and save the access token somewhere) before these API tests run?

+4
source share
1 answer

I would think that if the API is yours, then injecting an authentication component that can be packaged in unit test is a suitable design. If the API is not yours, then in your unit tests you only need to check how you process the API response. The API itself can be ridiculed.

+1
source

All Articles