Home > Back-end >  Integration test `enterText` method not working on profile or release mode
Integration test `enterText` method not working on profile or release mode

Time:02-11

Test passes in debug mode but not in profile or release mode. It does not enter text when calling enterText even if the input has focus. In debug mode it enters the text without problems.

CodePudding user response:

This is an issue, or more exactly a difference between how integration-tests work in debug vs profile or release.

TLDR

Basically if you're not in debug mode you have to call binding.testTextInput.register() in order for tester.enterText to work.

  final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized() as IntegrationTestWidgetsFlutterBinding;

// Necessary for being able to enterText when not in debug mode 
  binding.testTextInput.register();

This will permit to call enterText during integration testing. As a caveat this will disable the use of real keyboards during the test, but most of the times that is not the case.

Why does that happens?

Because in debug mode this is permitted via an assert which don't work on profile or release modes. See source code

  • Related