Closed
Description
Hi, first of all I really admire the simplicity.
but somehow I find it difficult to implement in my project.
so my project consist of multiple libraries in which consist of multiple api call from each Library.
I've followed all the guide given but still unable to mock the rest data (the RESTMock doesn't intercept the API call)
defaultConfig {
testInstrumentationRunner 'io.appflate.restmock.android.RESTMockTestRunner'
}
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
androidTestCompile ('com.github.andrzejchm.RESTMock:android:0.2.2') {
exclude module: 'okhttp'
}
exclude because of some conflict of versioning.
In my test:
public class SomeTest {
@Rule
public ActivityTestRule<LauncherActivity> mActivityTestRule = new
ActivityTestRule<>(LauncherActivity.class);
@Before
public void startUp() {
RESTMockServer.reset();
retrofit = new Retrofit.Builder()
.baseUrl(RESTMockServer.getUrl())
.build();
}
@Test
public void someTest() {
RESTMockServer.whenPOST(RequestMatchers.pathContains("customer/password_reset"))
.thenReturnEmpty(200);
// do something here and there
}
@After
public void tearDown() throws Exception {
HelperTool.clearApplicationData(context);
}
}
Above are some part of the code, I'm using espresso as you can notice in my gradle. when I run the code, the logcat still showing me that it points to my backend server. instead of RESTMockServer.getUrl()
Is there anything I missed here? Sorry still new in this
Metadata
Metadata
Assignees
Labels
No labels