0

The app I am trying to test makes use of feature toggles to enable/disable certain parts of the app. However, the tests I've written are for all the features. When a user logs in, this will fetch the feature toggles from a REST service (using a class which uses the generated openapi) so the app knows what to show and what not to show.

Now I want to include those feature toggles in my tests, so that the corresponding tests are skipped and don't just fail if some parts aren't enabled. However, when I try to include the class that does the call, I get problems with dart:ui in the console, and the test no longer runs. When I (recursively) check the imports on those service classes, there are some imports to widgets.dart, so I guess that's the problem. I tried removing most of it, but since we're using Localized strings for error messages etc. it's getting to be a very cumbersome job to remove all of that from those files.

So before I continue doing that, I was wondering if there is any easy way to include a call to a REST service in an integration test?

I checked the Flutter drive documentation, and searched for some similar questions online but haven't really found anything similar.

sime
  • 1
  • You could look into mocking the REST service, then write tests around behaviour when different flags are enabled/disabled and force them by changing the mocked response. [Read more](https://flutter.dev/docs/cookbook/testing/unit/mocking). – superhawk610 Mar 24 '21 at 20:48
  • OK, thanks, I'll have a look at that documentation. At the moment I added a check in each test to see if the element which is toggleable by the feature toggle is present, and if not, just skip that particular test completely. That works as well, but it feels a bit hacky to be honest. – sime Mar 25 '21 at 14:24

0 Answers0