Skip to content

An example app that is used in Devera Flutter course to demonstrate the testing in Flutter.

Notifications You must be signed in to change notification settings

hungnm138/devera-flutter-example-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo

Platform Flutter Made with Love

Buy me a coffee

Flutter Testing Examples

An example app that demonstrates how to test your app in Flutter.


Getting Started

This project is used in Devera Flutter course to demonstrate how to test your Flutter app.

Introduction

The more features your app has, the harder it is to test manually. Automated tests help ensure that your app performs correctly before you publish it, while retaining your feature and bug fix velocity.

Automated testing falls into a few categories:

  • A unit test tests a single function, method, or class. Test executed on the unit level, that is, very small (often atomic) pieces of code, such as individual classes or functions. Unit tests verify that one particular unit functions correctly and maintains its "contract" to the outside world in all cases.
  • A widget test tests a single widget (in other UI frameworks referred to as component test). Performed on the layer of individual Flutter widgets. Widgets tests verify whether -- or how often -- a widget is present in the widget tree.
  • An integration test tests a complete app or a large part of an app. Performed on multiple units of functionality with a focus on verifying the interplay between those units is correct and fulfills an expected outcome.

How to use

Step 1: Download or clone this repository.

https://github.com/hungnm138/devera-flutter-example-testing

Step 2: Run the tests

Run tests using IntelliJ or VSCode

The Flutter plugins for IntelliJ and VSCode support running tests. This is often the best option while writing tests because it provides the fastest feedback loop as well as the ability to set breakpoints.

IntelliJ
  • Open the fraction_unit_test.dart file (for example).
  • Select the Run menu.
  • Click the Run tests in fraction_unit_test.dart option (for example).
  • Alternatively, use the appropriate keyboard shortcut for your platform.
VSCode
  • Open the fraction_unit_test.dart file (for example).
  • Select the Run menu.
  • Click the Start Debugging option.
  • Alternatively, use the appropriate keyboard shortcut for your platform.

Run tests in a terminal

You can also use a terminal to run the tests by executing the following command from the root of the project (for example):

flutter test test/basic_unit_test/fraction_unit_test.dart

For the integration test:

flutter drive --target=test_driver/app.dart

For more options regarding unit tests, you can execute this command:

flutter test --help


Pub Packages

Package Usage
HTTP A composable, multi-platform, Future-based API for HTTP requests.
Flutter Bloc State management with BLoC pattern
Provider State management and context based DI
Bloc Test A testing library which makes it easy to test blocs. Built to be used with the bloc package.
test A full featured library for writing and running Dart tests across platforms.
Mockito A mock framework with APIs for Fakes, Mocks, behavior verification, and stubbing.

Conclusion

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Also, visit the Devera Academy website or Facebook fanpage to find out more about the courses.


Buy Me A Coffee

About

An example app that is used in Devera Flutter course to demonstrate the testing in Flutter.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published