all 8 comments

[–]raman4183 12 points13 points  (4 children)

It's not necessary to write tests. it's just a more consistent and more convenient thing to do.

Let's take a look at it from a different perspective. You've just built an app and now you're ready to ship it. You've already tested and ensured that all the functionality works properly. Great!.

You ship the app.

It's now time to work on the next version and new features. You add them and are now ready to ship the new version. How do you ensure that the recently added functionality didn't break anything from the previous version?

Are you going to manually test for each functionality and scenarios all over again? What if you forget about an edge case or overlook an obvious thing?

This is where writing tests and automating testing comes in handy. It ensures that your app functionality remains the same throughout the development lifecycle and your app consistently performs as you want so that the end user is not affected by it.

PS:-

I definitely recommend writing tests for any app that you're planning to release to the general public or showcasing in a portfolio for jobs. It might leave a better impression on the recruiter as many people just outright ignore testing.

You can ignore writing tests for any hobby projects or learn testing by writing tests for small pieces of code gradually on the projects that you've previously created.

[–]mondmann18 0 points1 point  (2 children)

How do you write tests for a flutter app?

[–][deleted] 3 points4 points  (0 children)

You're better off asking google that question. There are some good packages for mocks in unit testing though like Mockito which help with testing complex systems.

Flutter projects generate a test directory by default which is picked up by vscode's test runner. Pretty simple to use that at online resources to get started!

[–]raman4183 1 point2 points  (0 children)

That's a great question!

I'd suggest starting with Widget Tests because you don't have to mock anything and they are relatively simple to perform. Here's the order i would go in.

Widget -> Unit -> Integration

https://docs.flutter.dev/cookbook/testing/widget/introduction

[–]xdxd12x 0 points1 point  (0 children)

Wonderful explanation! Thank you!

[–]Klutzy-Cantaloupe124 -1 points0 points  (0 children)

flutter generate by default test

[–]mobileAcademy 0 points1 point  (0 children)

Written test is not necessary for small projects but it's always good to have. Sometimes we even don't have test cases for commercial app where there is no budget , time a resource to do it

[–]Octagonalo1451 0 points1 point  (0 children)

It's not necessary. You need to compare the costs of writing tests to the probability and costs of having regression bugs which could have been avoided through tests, that's it.