Skip to main content
Transform your testing process with: Real Device Features, Company-wide Licences, & App Percy
No Result Found

Run your Flutter integration tests for iOS

Integration tests are used to test how individual code works together and to capture the overall performance of an app. The integration_test package, provided by Flutter, is used to write integration tests for your Flutter app.

Prerequisites

Prepare iOS Flutter test package for testing

Launch the Xcode Application.

On Xcode, open ios/Runner.xcworkspace in your app’s iOS folder.

Click File > New > Target.

In the Target window, create a new Target by clicking Unit Testing Bundle under the Test section.

Rename the Product Name to RunnerTests in the Target window. Set the Target to be Tested to Runner and set the language Objective-C.

Ensure that the iOS Deployment Target setting in the Build Settings section for the RunnerTests file matches the setting in the Runner file.

Add a test file RunnerTests.m to a new target file in Xcode. This file acts as the entry point for your tests and executes the flutter wrapper. Add the following code snippet to the file:

Copy icon Copy

Add the new test target to ios/Podfile by embedding it in the existing Runner target.

Copy icon Copy

Run the following command to build <file_name>.dart:

Copy icon Copy

Execute the following script at the root of your Flutter app:

Copy icon Copy

Verify locally that your tests are successful by running the following command:

Copy icon Copy

Upload your test package

Upload your iOS app test package (<ios_test_package_name> in step 9) in .zip format to BrowserStack servers using the REST API request.

The following sample cURL command shows how to upload the test package:

A sample response for the above request is as follows:

{
   "test_package_name":"<ios_test_package_name>.zip",
   "test_package_url":"bs://3f8ca850476a7c26d4698225e32b353c83cac7ed",
   "test_package_id":"3f8ca850476a7c26d4698225e32b353c83cac7ed",
   "uploaded_at":"2022-07-21 14:55:59 UTC",
   "expiry":"2022-08-20 14:55:59 UTC",
   "framework":"flutter-integration-tests",
}

The value of the test_package_url parameter in the response is used to specify the application under test when you run your package.

Run iOS Flutter integration tests

After you upload your test package to BrowserStack servers, send an API request to start the test execution as shown in the following sample cURL request:

Select device
This device is not available in the free plan. Please upgrade to paid plan.
 

A sample response for the request is as follows:

{
  "message": "Success",
  "build_id": "f6f6d4214ebc3ccab9814d8090f5838644b0dc72"
}

The build_id is used to uniquely identify your build in App Automate.

View test results

After you start Flutter integration tests execution using the REST API, visit your App Automate dashboard to view your test results, debugging logs, and overall test details.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle