As with so many things in life, there is no such thing as the "better testing approach." You will need both functional tests and unit tests. Unit tests are validation for functions individually, and functional tests test your application as a whole. That being said, there are pros and cons to both approaches.
Functional tests versus unit tests
Unit test pros and cons
The pros of unit testing are as follows:
- It can validate a function 100%.
- It finds errors quite easily.
- Tests are quickly executed and repeated.
The cons of unit testing are as follows:
- It cannot easily test database operations.
- It struggles to dynamically test functions.
It is worth noting that web applications specifically are almost always doing...