GetX

Robot Testing is an end-to-end (E2E) technique that mimics a human. Its main advantage is that it focuses on the WHAT and not the HOW we are testing it. When a requirement changes or as our project or application envolves, we can continue to use the robot tests and its components. Yootube video :  https://youtu.be/L7sJGihkNr8

 

Let’s see a sample of a testing scenario with the Robot Pattern :

We use the integration_test package for writing integration tests. Add the plugin to your pubspec.yaml file as a development dependency

 

Using Robot Pattern for testing

 

Instead of writing all the tests in one file, we basically create robots per screen and then use the integration testing tools to test our application.

 

Take a look to the  file ‘home_screen_robot.dart‘ already created lib/integration_test/robots/home_screen_robot.dart into our project  flutter App

Note :  Every robot takes in the WidgetTester as a constructor parameter and defines the methods as required by that screen

Inside our, app_test.dart we initialize the HomeScreenRobot y DetailScreenRobot

and inside thetestWidgets function we can  use the methods as per the behavior

Test the App

 

To run our integration tests, first, make sure the emulators are running, and then we run the following. Then you have some ways to run the test.

1.  Go to the terminal  (I’m using VSCode)  write there this :

     flutter drive \ –driver=test_driver/integration_test.dart \ –target=integration_test/app_test.dart

2. Create a scrip file integration_test.sh. The content will be the command : flutter drive \ –driver=test_driver/integration_test.dart \ –target=integration_test/app_test.dart

3. If you are using VSCode (like me!!) go to left panel and click on icon ‘testing’, you will find on the left , the list of tests that you’ve already created

 

 

Robot testing is an additional step that can increase the confidence in your ability to release your product to the market,
as well as decrease the cost and amount of manual testing needed, especially when there are regular releases that need to be tested.

This an Flutter App. Calculina.

Calculina App. It is used to make a quick calculation of the corresponding insulin units for each meal, for people who suffer from diabetes, and need to calculate the units of rapid insulin. With its elegant design, easy and understandable, people can interact with Calculina and understand very quickly how to use the App to get the calculation they need. You can also share this result on the social networks that the device has installed.

 

 

 

  • GetX has 3 basic principles. This means that these are the priority for all resources in the library: PRODUCTIVITY, PERFORMANCE AND ORGANIZATION.

Well, the first concept that we have to keep on mind is  WE DON’T CARE ABOUT THE CONTEXT!!, why??? because getX manages that for us!!…

You do not need context to navigate between routes, so you are not dependent on the widget tree (visualization) for this. You don’t need context to access your controllers/blocs through an inheritedWidget, so you completely decouple your presentation logic and business logic from your visualization layer. You do not need to inject your Controllers/Models/Blocs classes into your widget tree through MultiProviders. For this, GetX uses its own dependency injection feature.

Go to official documentation

Before, I want to show , how this project is structured,

Well , today we are going to explain in detail the first, part of this video, Showing an snackbar using GetX.

1.Step install dependencies :

(Go to  your pubspec.yaml file, in your flutter project)

In this example we are going to need two additional dependencies: folding cell, google_fonts, awesome packages!!

2.Change file Main.dart

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widgetbuild(BuildContextcontext) {
return GetMaterialApp(
title:’Flutter GetX’,
debugShowCheckedModeBanner :false,
theme:  ThemeData(primarySwatch:Colors.blue,),
home: FoldingCell(),
initialBinding: MyBindings(),);}}

Our Main.dart file should return Get MaterialApp instead of traditional MaterialApp

3.Create a file  call folding_main.dart.

( Now is the time to use the pack folding cell Go to package )In this point, we are going to build , two main widgets, that we need frontWidget and innerWidget to fold and unfold. (see details on github…. https://github.com/Liliana99/my_getx)

Now we need to create our only controller , it so amazing, only for one controller !! ok , let’s go:

4.Create a folder call controllers, into their create a file call main controller.dart. path : lib/controlllers/main_controller.dart

Our controller needs to extends GetxController, it comes from Getx library. We create the get to have access in different places. So it is all, we’ve already injected our controller in the UI.  Goal accomplished, show that GetX does not need to call context to display snackbar!! . In my next articles, we are going to deep will the access with controllers and binding