Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Write UI tests #45

Open
RiccardoM opened this issue Jun 29, 2020 · 1 comment
Open

Write UI tests #45

RiccardoM opened this issue Jun 29, 2020 · 1 comment
Labels
kind/enhancement Enhancement of an existing feature type/tests Issue to improve the current test suite of the app
Projects

Comments

@RiccardoM
Copy link
Contributor

Context

Currently we have a test coverage of ~ 18% which in my opinion is very low compared to the 70-80% coverage that is recommended for most projects.

This is partly due to the fact that most of the code we currently have is UI-related, and I've personally tested only the non-UI code which makes up for quite a small part of the overall code lines.

In order to solve this problem, we should start implementing UI tests. Following, some references I've found that might be useful when writing such tests.

References

Bloc tests

In order to properly test blocs, we should use the concepts outlined inside the Testing section of the Bloc documentation, which highlights how Bloc should be tested independently from other components.

When testing Bloc what I suggest to do is not use the create method that they have. Instead, use the public constructor passing mocked arguments when needed. This should ensure that the BuildContext is never used (as it should).

Widget tests

The second type of tests that should be done are Widget tests. These allow to test single widgets independently and make sure they work properly. An introduction on these kind of tests can be found inside the official Flutter documentation.

Integration tests

Finally, integration tests should be created in order to test the integration between a lot of widgets and how they react. A nice guide on these kind of tests can be found inside Flutter docs.

Implementation roadmap

What I suggest we do is create multiple PRs that over time implement all these tests when different bugs are found. This should ensure we do not over-due something, and also that we build proper tests that we need.

What do you think @ryuash

@RiccardoM RiccardoM added kind/enhancement Enhancement of an existing feature type/tests Issue to improve the current test suite of the app labels Jun 29, 2020
@RiccardoM RiccardoM added this to To do in Mooncake via automation Jun 29, 2020
@RiccardoM
Copy link
Contributor Author

An example of widget tests has been written inside the riccardo/ui-tests branch

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/enhancement Enhancement of an existing feature type/tests Issue to improve the current test suite of the app
Projects
No open projects
Mooncake
  
To do
Development

No branches or pull requests

2 participants