Sitelet https://github.com/andrzejchm/RESTMock/issues/68
Skip to content

Unable to get RESTMock to work with external libraries of RESTapi #68

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(/sitelet?url=https%3A%2F%2Fgithub.com%2Fandrzejchm%2FRESTMock%2Fissues%2FRESTMockServer.getUrl%28))
                .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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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