Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 2.01 KB

README.md

File metadata and controls

61 lines (45 loc) · 2.01 KB

Integration Testing with Permissions

Flutter issue #12561 describes problems with running Flutter Driver when there are apps that require permissions.

This sample demonstrates how to work around these issues. It's integration tests must get location permission to pass. (The unit test uses a mock version of the location plugin.)

Run on an Android device using Flutter Driver:

Use the adb command to enable the permssions needed in your tests before running flutter drive:

adb shell pm grant <appId> android.permission.ACCESS_COARSE_LOCATION
adb shell pm grant <appId> android.permission.ACCESS_FINE_LOCATION

flutter drive \
  --driver=integration_test/driver.dart \
  --target=integration_test/location_test.dart \
  -d <deviceId>

You can determine which permissions you need to set by referencing the Manifest.permission documentation. Use this command for any permission with the "dangerous" level to prevent the app from displaying a dialog.

Run on an iOS device Flutter Driver:

Install AppleSimulatorUtils:

brew tap wix/brew
brew install applesimutils

Run applesimutils to enable permissions before running flutter drive:

applesimutils --byId <deviceId> --bundle <appId> --setPermissions location=always

flutter drive \
  --driver=integration_test/driver.dart \
  --target=integration_test/location_test.dart \
  -d <deviceId>

Tips

  • Set the iOS location by opening the Simulator and selecting Features -> Location -> Custom Location.
  • The iOS bundle identifier is camelCase (com.example.integrationTestPermissions) and Android app ID is snake_case (com.example.integration_test_permissions)
  • See the full list of Android permissions Manifest.permission documentation
  • See the full list of iOS permissions by running applesimutils --help