After a few more years of coding and working on projects I'll provide an answer to my own question.
Yes, you should write unit tests. End to end tests are harder to write and brittle especially if they're relying on UI components.
If you're using a framework like Django or Rails (or your own custom classes) you should have a form class that will handle validation of the form. You'll also have view classes that display rendered templates and the form and handle GET and POST requests.
In an end to end test you would:
- get the url
- fill in the form with valid data
- post the form to the url
- check to make sure the database has been updated or some action has been executed as a result of the valid form
You're testing a lot of code and your coverage will be pretty good but you're only testing the happy path when everything goes right. How do you ensure that the form has the right validation in it? What if that form is used on multiple pages? Do you write yet another end to end test?
Let's try this again with unit tests:
- test the view GET method
- test the view POST method with a fake/mock form
- test the form with valid data
- test the form with invalid data
- test the form's side-effects
By using unit tests, you're testing smaller pieces of code and the tests are specific and easier to write. When you combine this with TDD (Test Driven Development) you get higher quality code.
The ease of writing unit tests shouldn't be dismissed because when you're on a project that has no automated testing, you have to start somewhere. Starting with unit tests is easier and faster and lets you immediately start testing for bugs rather than only for the happy path.