Skip to content

Commit 6f38bfb

Browse files
committed
updated the flutter docs
1 parent 35751f2 commit 6f38bfb

File tree

1 file changed

+60
-7
lines changed

1 file changed

+60
-7
lines changed

docs/getting-started-with-flutter-dart-android-automation.md

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ slug: getting-started-with-flutter-dart-android-automation/
1616

1717
import CodeBlock from '@theme/CodeBlock';
1818
import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys";
19+
import Tabs from '@theme/Tabs';
20+
import TabItem from '@theme/TabItem';
1921

2022
<script type="application/ld+json"
2123
dangerouslySetInnerHTML={{ __html: JSON.stringify({
@@ -58,12 +60,63 @@ If you do not have any **Flutter Android** app (.apk) and an **Flutter Test Suit
5860

5961
## Run Your First Test
6062

61-
### Step 1: Upload Your Application
63+
### Step 1: Create your Android Flutter app and test suite for testing
64+
For testing, you need to build a Flutter app and test suite. You can create Flutter applications and test suites using either Flutter cli or Gradlew. The steps below demonstrate how to create apks with Gradlew.
65+
66+
- Create an instrumentation test file in your application's directory `android/app/src/androidTest/java/com/example/lambdatestSampleApp/`. Replace **com**, **example**, and **lambdatestSampleApp** values with those from your app's package name.
67+
68+
```java title="SampleTest.java"
69+
package com.example.lambdatestSampleApp;
70+
import androidx.test.rule.SampleTestRule;
71+
import dev.flutter.plugins.integration_test.FlutterTestRunner;
72+
import org.junit.Rule;
73+
import org.junit.runner.RunWith;
74+
import com.example.lambdatestSampleApp.Sample;
75+
@RunWith(FlutterTestRunner.class)
76+
public class SampleTest {
77+
@Rule
78+
public SampleTestRule<Sample> rule = new SampleTestRule<>(Sample.class, true, false);
79+
}
80+
```
81+
82+
- Update your application's `lambdatestSampleApp/android/app/build.gradle` file to use androidx's version of `AndroidJUnitRunner` and include the `androidx` libraries as dependencies.
83+
84+
```java title="build.gradle"
85+
android {
86+
...
87+
defaultConfig {
88+
...
89+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
90+
}
91+
}
92+
dependencies {
93+
testImplementation 'junit:junit:4.12'
94+
androidTestImplementation 'androidx.test:runner:1.2.0'
95+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
96+
}
97+
```
98+
99+
- Use the following `Gradle` commands to build an instrumentation `test.apk` file(test suite) using the `Sample.java` created in the `androidTest` directory as mentioned in step 1.
100+
101+
```java title="Terminal"
102+
//Go to the android folder which contains the "gradlew" script used for building Android apps from the terminal
103+
pushd android
104+
//Build an Android test APK (uses the Sample.java file created in step 1)
105+
./gradlew app:assembleAndroidTest
106+
//Build a debug APK by passing the integration test file
107+
./gradlew app:assembleDebug -Ptarget="INTEGRATION_TEST_FILE_PATH"
108+
//Go back to the root of the project
109+
popd
110+
```
62111

63-
Upload your **android** application (.apk 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:
112+
:::info
113+
Avoiding this step might result in **No Tests Ran** issue on the dashboard
114+
:::
64115

65-
import Tabs from '@theme/Tabs';
66-
import TabItem from '@theme/TabItem';
116+
117+
### Step 2: Upload Your Application
118+
119+
Upload your **android** application (.apk 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:
67120

68121
**Using App File:**
69122

@@ -99,7 +152,7 @@ Response of above cURL will be a **JSON** object containing the `App URL` of the
99152

100153
:::
101154

102-
### Step 2: Uploading Test Suite
155+
### Step 3: Uploading Test Suite
103156

104157
Upload your **test suite** (.apk 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:
105158

@@ -137,7 +190,7 @@ Response of above cURL will be a **JSON** object containing the `App URL` of the
137190

138191
:::
139192

140-
### Step 3: Executing The Test
193+
### Step 4: Executing The Test
141194

142195
#### Basic Authentication
143196

@@ -200,7 +253,7 @@ curl --location --request POST "https://mobile-api.lambdatest.com/framework/v1/f
200253
</TabItem>
201254
</Tabs>
202255

203-
### Step 4: View Test Execution
256+
### Step 5: View Test Execution
204257

205258
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](https://appautomation.lambdatest.com/build).
206259

0 commit comments

Comments
 (0)