Skip to content

Mocking

Orhan Obut edited this page Aug 9, 2015 · 2 revisions

One of them most powerful feature of wasp, you can easily mock your network calls by using mock annotation.

@Mock Uses auto generate feature mock regarding to your response type

    @Mock
    @GET("/user")
    void fetchUser(
          Callback<User> callback
    );

@Mock(path="users.json") : Uses local file to generate mock. Local files must be under assets folder. This will return a response with the generated content by given path, with the status code 200

    @Mock(path="user.json")
    @GET("/user")
    void fetchUser(
          Callback<User> callback
    );

@Mock(statusCode=404) : Returns a fail response with status code 404

    @Mock(statusCode=404)
    @GET("/user")
    void fetchUser(
          Callback<User> callback
    );

@Mock(statusCode=201) : Returns a success with the status code 201 and auto generated response

    @Mock(statusCode=201)
    @GET("/user")
    void fetchUser(
         Callback<User> callback
    );
Clone this wiki locally