Code Monkey home page Code Monkey logo

movie_catalog's Introduction

Movie Catalog

A demo application to learn the testing techniques in Flutter.


Table of contents


There are three types of automated test in Flutter

1. Unit test

A unit test tests a single function, method, or class. The goal of a unit test is to verify the correctness of a unit of logic under a variety of conditions.

To run unit test on this app, run command flutter test test/unit_test.dart

On successful completion of the test you will get an output 00:08 +4: All tests passed! Here, +4 tells that 4 tests successfully passed. Similarly a +3 -2 would mean that 3 tests passed and 2 tests failed. Unit tests are very fast.

2. Widget test

What is a widget test? Widget test in action
A widget test (in other UI frameworks referred to as component test) tests a single widget. The goal of a widget test is to verify that the widget’s UI looks and interacts as expected.

To run widget test on this app, run command flutter run test/widget_test.dart.

Widget tests are slower than unit tests but still fast enough that it is hard to see the tap on BookmarkIcon button.

3. Integration test

An integration test tests a complete app or a large part of an app. The goal of an integration test is to verify that all the widgets and services being tested work together as expected.

To run integration test on this app, run command flutter drive --target=test_driver/app.dart.

Integration tests are also used to perform a specific task and record a performance timeline better known as Performance profiling. Integration tests work as a pair: first, deploy an instrumented application to a real device or emulator and then “drive” the application from a separate test suite, checking to make sure everything is correct along the way. Integration tests are the slowest.

Integration test in action

Golden test

What is a Golden test? How does a golden file look like?
A golden test is an IO action that writes its result to a file. To pass the test, this output file should be identical to the corresponding golden file, which contains the correct result for the test.
Golden test are a special type of widget test.

To run golden test on this app, run command flutter test test/golden_test.dart.

The term golden file refers to a master image that is considered the true rendering of a given widget, state, application, or other visual representation you have chosen to capture.But these images are not simply a screenshot of the UI, these are special type of images called goldens which are created using command flutter test --update-goldens test/golden_test.dart.

Reference

To know more about testing, refer to official Flutter documentation flutter.dev/docs/testing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.