Uploaded by Sohaib Arafat

Masaaq

advertisement
Sohaib Arafat & Jehad Hmoudah
CI, Static Analysis & Test Coverage
As we are working with Flutter, we encountered some limitations when it comes to using
certain tools like SonarCloud, which unfortunately does not support Flutter. However, we
discovered an all-in-one solution that provides everything we need. We opted to use
CodeMagic for testing, analyzing, and deploying our project. With its comprehensive
features, we were able to seamlessly carry out these tasks without any issues.
Continuous Integration:
CodeMagic also offers an Apple Mac Mini with an M1 chip that can be used as a CI server.
The best part is that they offer up to 500 minutes of usage for free, after which a small fee is
charged. The platform provides various options and settings to build and deploy apps,
making the process seamless and efficient. With CodeMagic, the app is automatically built
and deployed to their servers each time there is a push to the remote repository, ensuring
that the latest version of the app is always available for testing and deployment.
Sohaib Arafat & Jehad Hmoudah
You can visit this build on masaaq-beta.codemagic.app.
Static Analysis:
Codemagic offers the capability to run tests and perform static analysis on Flutter based on
the Standard Flutter/Dart lint. It goes beyond just building and deploying the app, but also
provides insights into its quality. With this tool, every commit pushed to GitHub is
automatically marked as pass or fail based on the results of the analysis.
As you can see, most of the bad smells were related to importing test and
development packages into production code. We fixed these bad smells by removing
the test and development packages from our production code. We also fixed the
minor performance issues related to using the const modifier.
Sohaib Arafat & Jehad Hmoudah
Builds before and after fixing bad smells:
Commit 435d3d0 with 20 bad smells.
Commit 8cd7bbb with 0 bad smells.
Sohaib Arafat & Jehad Hmoudah
Here is a sample of the analysis performed by flutter analyzer:
Sohaib Arafat & Jehad Hmoudah
We can provide the full analysis result upon request.The analysis is for 40+ files so
we can’t fit the entire result in the report.
Sohaib Arafat & Jehad Hmoudah
Testing and tests Coverage:
We wrote 34 different tests for all of our 8 features we made for this project.
Flutter comes with a built-in test coverage generator that creates an lcov.info file. We can
then use genhtml to convert this file to HTML, which provides us with a comprehensive
coverage report. The following pages display the full coverage report, giving us a clear
picture of the code that has been tested and those that require further testing.
Flutter test coverage command
Lcov to Html with Genhtml
Sohaib Arafat & Jehad Hmoudah
Top view of the coverage report
Utilities directory coverage
Files viewer coverage
Field builder coverage
Managers directory coverage
Sohaib Arafat & Jehad Hmoudah
Our total coverage was 41%.It's because we only test 8 features out of the entire 7000 lines
app.In addition to this,the flutter coverage is strict about testing booth the logic and the UI
related to it.For example the themes manager had a coverage of 11%:
This is a simple example showcasing the concept of Flutter coverage. In this case, the
themes manager consists of approximately 400 lines of code, primarily comprising colors
and constants that aren't included in the coverage calculation. It's important to note that the
coverage percentage of 41% is based on the tested features and does not encompass all UI
components present in the application.
Download