8000 Unable to get RESTMock to work with external libraries of RESTapi · Issue #68 · andrzejchm/RESTMock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
< 8228 bdi class="Box-sc-g0xbh4-0 lhNOUb markdown-title" data-testid="issue-title">Unable to get RESTMock to work with external libraries of RESTapi #68
Closed
@syariffudinzo

Description

@syariffudinzo

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0