Jonjie's avatar
Level 12

Why do we need other package to test?

Hi. I'm just thinking why do we really need to use other packages like PHPUnit to test our application? Why not just using the application on how users use it? Like for example if we have a registration functionality, why not just test it by just using the application itself? Sorry but I'm really confused about it. I also read this https://softwareengineering.stackexchange.com/questions/116076/why-use-phpunit-when-traditional-manual-testing-can-be-used, but still confusing.

0 likes
2 replies
lostdreamer_nl's avatar

because manual testing takes time.... A lot of time.... And as your program grows, it will take even more time.

For instance, right now I'm working for an employer that does not have any unit tests in it's main product.

It's product is being used by 1000's of other companies (each having 100's - 1000's of users).

When I make a change in some core functionality, the whole system has to be tested (manually) for at least 10 different customers (because the software can be setup in many different ways).

So: When I now make a 5 minute change, it takes over 20 hours of manual testing.

If we'd have unit tests for all small pieces, and integration tests to see how those pieces play together, and functional tests (the automated way of 'testing the website including the forms') I could do all those tests myself with a single command, and know if I broke something within a few minutes.

Can you try to estimate the hours lost on ever hour of programming?

Having no tests and not being allowed to write any is the reason I'm leaving this job next week ;)

1 like
joshuafranks's avatar

Test Driven Development is far more reliable and effective than manual testing. By having a comprehensive test suite, you give yourself the peace of mind that everything is covered. You can write all sorts of tests that cover a number of eventualities and reliably assert that your code works.

This is especially useful when refactoring your code. When you make changes, you can run your tests and ensure that everything still works as you expect. Even subtle changes could have an adverse affect on other parts of your application and it's easy for things to go unnoticed.

The authentication that comes out of the box with Laravel is already reliable, but as your application grows and you start writing your own features - tests are incredibly useful. It's a pretty broad subject, but there are plenty of resources out there that can help you learn.

Another advantage, of course, is that you can drive out the core features of your application without any front-end work at all.

1 like

Please or to participate in this conversation.