Comments (5)
@andrzejchm Could you expand README tutorial with above steps? It could be helpful for the new RESTMock users.
from restmock.
the best way to understand this is to take a look into androidsample
code within this repo. So:
in this dagger module, we build the retrofit object being used across the whole app. As you can see, there is a constructor parameter specifying the baseUrl. This one is being created in SampleApplication
class when the app is running normally with the real url for the production servers. While running tests, I'm using TestApplication
instead of SampleApplication
as an Application class for the app, and there I'm specifying RESTMock's server url as a base url instead of real production url, as you can see here:
https://github.com/andrzejchm/RESTMock/blob/develop/androidsample/src/androidTest/java/io/appflate/restmock/androidsample/TestApplication.java
In order to be able to specify different Application
subclass for tests and normal app run, you have to create a custom test runner, like in example: https://github.com/andrzejchm/RESTMock/blob/develop/androidsample/src/androidTest/java/io/appflate/restmock/androidsample/CustomTestRunner.java
and have it specified within your build.gradle
file
testInstrumentationRunner 'io.appflate.restmock.androidsample.CustomTestRunner'
as can be seen here: https://github.com/andrzejchm/RESTMock/blob/develop/androidsample/build.gradle
from restmock.
First things first:
- Did you specify a custom test runner that starts RESTMock before the tests start?
- Do you perform any API call within the tests, or are those being made within the
LauncherActivity
? If you have those calls within launcher activity, then you will have to make sure it does have a Retrofit configuration pointing to RESTMock's url. InSomeTest
you create new retrofit instance that is local to the test itself, but not to the app being tested.
from restmock.
- did you mean this?
b) RESTMockServerStarter
If you have your custom test runner and you can't extend RESTMockTestRunner, you can always just call the RESTMockServerStarter. Actually RESTMockTestRunner is doing exactly the same thing:
I thought it is the same thing, but I definitely will try it with both the dependencies and the RESTMockServerStarter
- it is being made in the
LaucherActivity
, and when you mean by
If you have those calls within launcher activity, then you will have to make sure it does have a Retrofit configuration pointing to RESTMock's url
does that mean i need to implement them in the main Application itself?
from restmock.
This is already a part of the readme as 6.
point in the Setup. I will add a reference to this issue though for better explanation
from restmock.
Related Issues (20)
- AndroidX compatability HOT 4
- SSLHandshakeException when using RESTMock HOT 1
- ConcurrentModificationException when resetting the server HOT 4
- Upgrading to OkHttp 4.0.0 HOT 5
- Question: What are your thoughts/plans on @Nullable @NotNullable annotations? HOT 2
- got Problem with relative paths from android gradle plugin 3.5.0 HOT 3
- Issue with Test not passing HOT 1
- Test delayed data streaming HOT 3
- Library not working for apps using current version of OkHttp (4.4.1) HOT 2
- Upgrading to OkHttp 4.5.0 HOT 3
- Crash with proguard HOT 1
- converting android sample project to Kotlin gives ClassNotFoundException HOT 4
- Any chance RESTMock can be moved off of Jitpack?
- Needs Explaination why we need to change base url in application HOT 3
- Regex support for URL matchers? HOT 1
- Version 0.3.2 is not working doing as the sample app HOT 2
- Repository miss a Changelog file HOT 1
- Android P support HOT 1
- Version 0.3.2 with HTTPS throws exception on API Level 28 HOT 3
- useHttps true in RESTMockTestRunner HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from restmock.