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.
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 theBuildContext
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