Table of Contents
Photo by Minku Kang on Unsplash
Introduction
In the prior post, we described a workflow to automate our take a look at suite working with Firebase and Codemagic.
On this posting, we are likely to overview the native configuration necessary on the fundamental Android project.
Upcoming time, we will test the CI/CD pipeline configuration and the effects just after operating the integration exams. So let’s get begun!
Speedy recap
Automation workflow
Make Firebase JobConfigure undertaking by incorporating an account providerPermit Cloud Tools Final result- Update underlying native Android venture
- Configure underlying indigenous Android Exam Runner
- Established up Codemagic pipeline
As stated before, we previously reviewed the to start with 3 goods, so let’s continue from merchandise quantity 4.
4. Update indigenous Android task
Configuration demanded in the “android” folder beneath our Flutter job is rather simple. Only 2 modifications are needed:
- Deliver up-to-day the Gradle model
- Increase the Google Solutions dependency
Updating Gradle
Gradle is the underlying make mechanism utilized in Android. When it will come down to setting up and jogging some Android app, Gradle does all the major-lifting for us.
Gradle is dispersed in 2 formats:
- the principal establish software alone (aka “gradle”)
- the helper script utilized when gradle is not offered (aka “wrapper”)
Some glitches could be thrown when using older versions of Gradle, so we have to update it by transforming following items:
- file “android/construct.gradle” (external, at venture stage)
- file “android/gradle/wrapper/gradle-wrapper.attributes“
On equally information, only thing we have to do is established at the very least the variation depicted on the screencaps.
Adding Google Providers dependency
Considering the fact that gradle is the indigenous build mechanism for Android, it also requires cares of 3rd celebration libraries and dependencies made use of in our project.
To get our assessments running instantly, we will have to include the following dependency in our native Android task:
classpath “com.google.gms:google-products and services:4.2.0”
Soon after that, open up a terminal, change from your present-day listing to the Android folder and then run:
./gradlew create
to force a rebuild.
5. Configure native Android Exam Runner
Less than the hood, our Flutter integration assessments will be executed on the underlying tests platforms. So, in Android, our Flutter integration assessments will turn into Android Instrumentation assessments. On iOS, they would be XCUI assessments, and they would required some configuration also.
2 variations are required right here as nicely to get our tests up and working on Android:
- configuring the gradle file
- incorporating a most important exercise file for take a look at
Gradle configuration
Android Instrumentation tests are operate on a different natural environment and use a specific item, termed Instrumentation, that grants accessibility to the application context and permits the execution of steps about the application less than exam.
The default Android undertaking shipped on a Flutter project does not include the configuration for Android Instrumentation, so we have to modify:
file “android/application/create.gradle” (inside, at module stage)
by location manually the testInstrumentation residence in the defaultConfig block:
and also including the adhering to libraries in the dependencies block:
Including a test Key Exercise
The instrumentation assessments will demand a unique most important entry position, as any other automated process.
In buy to present it, initial we make the pursuing listing hierachy:
/android/application/src/androidTest
Following that, we have to reply the bundle framework made in the “main” subset. On this job, that would be:
java.com.example.fooderlich
so, when introducing them each, we close up with a thing like:
/android/app/src/androidTest/java/com/example/fooderlich
Ultimately, once we have established the folder composition, we have to insert a most important examination exercise file. The code contained on this file is widespread to any undertaking, so it can be utilised as a template: the only detail we have to adjust is the challenge offer, as demonstrated in the subsequent screencap:
Recap
As you can see, the underlying configuration for our take a look at automation is fairly uncomplicated! On the previous article of this collection, we’ll check out the Codemagic set up so we comprehensive the complete workflow.
Sample challenge
Check out out the adhering to repository containing the complete project:
https://github.com/begomez/Flutter-Exam-Automation
Produce you upcoming time!