Flutter unit testing using Mockito

Intro:
This article is my first blog post on Medium.
I’ve come to Flutter recently and this transition makes me learn a lot these days. To better summarise the topic, the idea of this article was born.

“Senpai, why unit testing is important?”

When developers compile, run, debug, what do they do?

  • Safe refactoring and reimplementation of code
  • Positive impact on design
  • Introduces knowledge of code base

A bit of application context

A replicant is a fictional bioengineered being in the 1982 film Blade Runner, and in its 2017 sequel Blade Runner 2049. The Nexus-series of replicants are virtually identical to adult humans but have superior strength, speed, agility, resilience, and intelligence, to varying degrees depending on the model. A replicant can only be detected by means of the fictional Voight-Kampff test, in which emotional responses are provoked and a replicant’s nonverbal responses differ from those of a human. A version of the test, referred to as a Baseline, is taken by K in Blade Runner 2049 to detect any mental or empathic damage, for which failure means retirement.

import 'dart:io';String fixture(String name) => File('test/fixtures/$name').readAsStringSync();

After all, let’s see if we are not dealing with replicants by testing humans.

Conclusion

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store