id | title | sidebar_label | description | keywords | url | site_name | slug | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
getting-started-with-flutter-dart-ios-automation |
Flutter Dart Testing On LambdaTest - iOS |
Flutter Dart iOS |
This guide details running your first Flutter Dart test on real iPhones using LambdaTest's Real Device Cloud. |
|
LambdaTest |
getting-started-with-flutter-dart-ios-automation/ |
import CodeBlock from '@theme/CodeBlock'; import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys";
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify({ "@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [{ "@type": "ListItem", "position": 1, "name": "Home", "item": "https://www.lambdatest.com" },{ "@type": "ListItem", "position": 2, "name": "Support", "item": "https://www.lambdatest.com/support/docs/" },{ "@type": "ListItem", "position": 3, "name": "Getting Started With Flutter Tests on LambdaTest", "item": "https://www.lambdatest.com/support/docs/getting-started-with-flutter-dart-android-automation/" }] }) }} ></script>Flutter, an open-source UI toolkit created by Google, is a popular choice among developers to build natively compiled applications for mobile, web, and desktop from a single codebase. With Dart as its programming language, Flutter enables fast development of beautiful apps with a highly productive, extensible and open-source set of features.
In this guide, we will explore how to run your first Flutter Dart test on an iOS device using the LambdaTest Real Device Cloud. By combining the capabilities of Flutter Dart and LambdaTest, you can ensure the proper functioning of your app across different devices and make your app more reliable and robust.
- Flutter SDK installed on your system
- You will need a LambdaTest username and access key. To obtain your access credentials, purchase a plan or access the automation dashboard.
- Access to a Flutter Sample test suite (.zip).
:::tip
If you do not have any Flutter iOS test suite (.zip), you can run your sample tests on LambdaTest by using our sample 🔗 Flutter iOS.
:::
Upload your iOS test suite (.zip file) to the LambdaTest servers using our REST API. You need to provide your Username and AccessKey in the format Username:AccessKey
in the cURL command for authentication. Make sure to add the path of the appFile in the cURL request. Here is an example cURL request to upload your app using our REST API:
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
Using App File:
:::note
Response of above cURL will be a JSON object containing the App id
of the format - lt://APP123456789123456789123456789
and will be used in the last step.
:::
:::info You will need base64 encoded authentication in order to execute your Espresso automation test suite. You need to enter your username:accesskey here in order and click on encode to generate the base64 authentication. Take note of the base64 encoded authentication which needs to be added in the next step. :::
Once you have uploaded your test suite, you can execute your test by running the following command:
:::info Make sure to enter your basic authentication and app id (generated in the first step) in the below command. :::
curl --location --request POST 'https://mobile-api.lambdatest.com/framework/v1/flutter/ios/build' \
--header 'Authorization: Basic <Enter_Basic_Auth>' \
--header 'Content-Type: application/json' \
--data-raw '{
"testSuite": "lt://App_id",
"device": ["iPhone.*-16"],
"video": true,
"deviceLog": true,
"queueTimeout": 9000,
"network": true,
"build": "Flutter iOS"
}'
curl --location --request POST "https://mobile-api.lambdatest.com/framework/v1/flutter/ios/build" --header "Content-Type: application/json" --header "Authorization: Basic <Enter the Auth here>" --data-raw "{\"testSuite\": \"lt://APP_ID\",\"device\" : [\"Pixel 6-12\"], \"video\": true, \"deviceLog\": true, \"queueTimeout\" : \"9000\",\"idleTimeout\" : \"600\"\"network\": true,\"build\" : \"Flutter iOS\"}"
Once you have run your tests, you can view the test execution along with logs. You will be able to see the test cases passing or failing. You can view the same at LambdaTest Automation.
The following capabilities are supported:
- testSuite: Enter the app id generated while uploading the app. Example:
lt://APP123456789123456789123456789
- device: Enter the name and os version of the device in "DeviceName-OSVersion" format. Example:
iPhone 14-16
oriPhone 15 Pro-17
. You can also choose to use regular expression for device name such asiPhone.*-16
. - video: Generate video for all the tests that have run. Example:
true
. - queueTimeout: Enter the time in seconds for total execution time of the build. Example:
9000
. Minimum queueTimeout:1800
, Maximum queueTimeout:10800
- network: Boolean value to generate network logs. Example:
"network": true
. - build: Set the name of the Flutter iOS test build. Example:
My Flutter iOS
. - deviceLog: Boolean value to generate device logs. Example:
true
. - tunnel: Boolean value to run build via Tunnel. Example:
true
. - tunnelName: Name of the tunnel to be used in conjunction with
tunnel
capability. - region: String to device the region from which device will be allocated. Example -
eu
,us
,ap
.
You can run tests in parallel on multiple devices by passing the device name in comma separated format in the execute command as show below:
curl --location --request POST 'https://mobile-api.lambdatest.com/framework/v1/flutter/build' \
--header 'Authorization: Basic <Enter_Basic_Auth>' \
--header 'Content-Type: application/json' \
--data-raw '{
"testSuite": "lt://App_id",
"device": ["iPhone.*-16","iPhone 14-16","iPhone 15-17"],
"video": true,
"deviceLog": true,
"queueTimeout": 9000,
"network": true,
"build": "Flutter iOS - Parallel"
}'
:::tip
Do note that Flutter builds when run in parallel, result in separate builds being generated for each parallel run.
:::