1) Give you confidence that if you refactor something, when you do something silly it'll break the tests and show you where you went wrong quickly
2) Allow you as a developer to write new things in isolation, so you can run the code without needing to jump through any hoops to see that it's correct
I tend to write tests when the thing I'm developing isn't simple/cheap to access. Writing tests should help you do things faster, as well as stopping future you from doing daft things. Writing tests dogmatically however, is a waste, and if tests are hard or onerous to write, it shows that the application is probably poorly designed and architected.
1) Give you confidence that if you refactor something, when you do something silly it'll break the tests and show you where you went wrong quickly
2) Allow you as a developer to write new things in isolation, so you can run the code without needing to jump through any hoops to see that it's correct
I tend to write tests when the thing I'm developing isn't simple/cheap to access. Writing tests should help you do things faster, as well as stopping future you from doing daft things. Writing tests dogmatically however, is a waste, and if tests are hard or onerous to write, it shows that the application is probably poorly designed and architected.