Pinch.nl

Pinch is a well-known mobile development agency. From our office in Amsterdam we have been working with a passionate team of +/- 40 FTE since 2011. We create (more than 100) apps for well-known brands, media companies and start-ups.

Image by Yu Kato through Unsplash

Member-only story

Pcov: better code coverage for Flutter

3 min readDec 23, 2022

--

Testing can give you some great insights into the quality of your code, as well as provide you with a safety net when refactoring your code for example. Testing should be easy and fun, and with pcov things just got better for your Flutter projects!

The Flutter framework provides you with some great testing tools out of the box. You can easily run your tests using flutter test to see if all your tests are still passing. If you also want to have some insights on code coverage for your project, you can do that too by simply adding a coverage flag to the test command: flutter test --coverage. What is pcov solving then, and why did we create it in the first place?

Misleading code coverage

So, you decided you’re going to work on unit testing and take code coverage as one of your metrics to get some insights on that. You might already have a project with a couple of tests, so you run the flutter test --coverage command and see a coverage of 18%. Not great, but a good starting point at least!
When thinking about it again, that 18% sounds quite unexpected though. It’s a fairly large project and we hardly wrote any tests for it, then how can we get to 18% already?

Because flutter test --coverage only takes the files into account you actually touched in your tests!

--

--

Pinch.nl
Pinch.nl

Published in Pinch.nl

Pinch is a well-known mobile development agency. From our office in Amsterdam we have been working with a passionate team of +/- 40 FTE since 2011. We create (more than 100) apps for well-known brands, media companies and start-ups.

No responses yet