Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Needs Explaination why we need to change base url in application #118

Open
shahidlatif2007 opened this issue May 10, 2023 · 3 comments
Open

Comments

@shahidlatif2007
Copy link

RestAdapter adapter = new RestAdapter.Builder()
.baseUrl(RESTMockServer.getUrl())
.build();

You mentioned that we need to change base url in native code by using TestApplicatiion. Why you need to this. The interceptor needs to works irespective to URL. sometime application has multiple URL and some developer dont want to change the code. It will be helpful that you provide the explaination. I read the tutorial mentioned in above step. I need to integrate this library for Espresso Tests

@andrzejchm
Copy link
Owner

hey @shahidlatif2007 . this is because the library starts a test HTTP server. if you don't replace the base URL in your app, the app will target your servers and the mock library's HTTP server will not be responding with mock responses.

@shahidlatif2007
Copy link
Author

@andrzejchm Thanks for quick reply.

Why not MockWebServer uses this step as under the hood you are using that library. One of developer ask me this question. Why this library uses this step and why not MockWebServer library required this step.

@andrzejchm
Copy link
Owner

actually MockWebServer asks you exactly for the same thing. It first starts the server, saves the mock server's URL to a variable that is then passed to the app's code to use instead of real base URL:
CleanShot 2023-05-10 at 09 28 59@2x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants