Dio: How to stub the requests for tests cases

Created on 28 Feb 2019  Â·  2Comments  Â·  Source: flutterchina/dio

At this first, I'd like to say congrats for this awesome library!
I'm looking for ways to test it, there is an way to mock the results?

For example in http I usually do at this way on tests

      Client client = MockClient((request) async {
        return Response(json.encode(fakeResponse), 200);
      });

Most helpful comment

Thxs, what do u think about create a readme or wiki about tests?

All 2 comments

you can do this by custom HttpClientAdapter。 Examples:

  1. mock_adapter (Used in dio_test.dart)
  2. custom adapter demo

Thxs, what do u think about create a readme or wiki about tests?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vico-aguado picture vico-aguado  Â·  6Comments

codeThe0 picture codeThe0  Â·  6Comments

keluokeda picture keluokeda  Â·  3Comments

HelgeSverre picture HelgeSverre  Â·  6Comments

Dmitry-N-Medvedev picture Dmitry-N-Medvedev  Â·  3Comments