U-Report is a social messaging tool and data collection system developed by UNICEF to improve citizen engagement, inform leaders, and foster positive change. The program sends polls and alerts to its participants, collecting real-time responses, and subsequently publishes gathered data.
To ensure the U-Report app continues to work as developers add more features or change existing functionality, writing tests for every custom built widget should be an integral part of the development process.
Unit tests are handy for verifying the behavior of a single function, method, or class. The test package provides the core framework for writing unit tests, and the flutter_test package provides additional utilities for testing widgets.
Carry out following steps to add a widget test for the bottom navigation widget:
[x] Create a new branch from develop called bottom-navigation-test. Hint: git checkout -b new-branch `existing-branch
[x] Create a new file dart file under test/ folder and name it bottom_navigation_widget_test.dart
[x] Open bottom_navigation_widget_test.dart file and import following packages:
import ‘package:flutter/material.dart’;import ‘package:flutter_test/flutter_test.dart’;
[x] Write a test for the tab navigation widget.
[x] Combine multiple tests in a group.
[x] Run the tests in terminal using: flutter test
[x] Commit the changes (as a single commit).
[x] Push changes to Github. Hint:git push --set-upstream origin bottom-navigation-test
To ensure the U-Report app continues to work as developers add more features or change existing functionality, writing tests for every custom built widget should be an integral part of the development process.
Unit tests are handy for verifying the behavior of a single function, method, or class. The test package provides the core framework for writing unit tests, and the flutter_test package provides additional utilities for testing widgets.
Carry out following steps to add a widget test for the bottom navigation widget:
develop
calledbottom-navigation-test
. Hint: git checkout -bnew-branch
`existing-branchtest/
folder and name itbottom_navigation_widget_test.dart
bottom_navigation_widget_test.dart
file and import following packages:import ‘package:flutter/material.dart’;
import ‘package:flutter_test/flutter_test.dart’;
flutter test
git push --set-upstream origin bottom-navigation-test
Hints: https://medium.com/flutterpub/writing-and-running-widget-tests-from-android-studio-d63b9fea21c5 https://flutter.dev/docs/cookbook/testing/unit/introduction