Square retrofit server mock for testing

前端 未结 11 1419
栀梦
栀梦 2020-12-07 06:54

What\'s the best way to mock a server for testing when using the square retrofit framework.

Potential ways:

  1. Create a new retrofit client and set it

11条回答
  •  南笙
    南笙 (楼主)
    2020-12-07 07:31

    Mockery (disclaimer: I’m the author) was designed just for this exactly task.

    Mockery is a mocking/testing library focused on validating networking layers with built-in support for Retrofit. It auto-generates JUnit tests based on the specs of a given Api. The idea is not to have to write manually any test; neither implementing interfaces for mocking server responses.

提交回复
热议问题