Looking through the docs, I see that PHPUnit only offers these functions:
http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.assertions
All of them can be very easily implemented in a custom testing script, within less than 1K lines...
PHPUnit has 2 MB of files (around 200), which include a huge amount of classes. Also, PHPUnit only runs from the command-line :(
Wouldn't creating my own script be a better idea?
With unit testing we test each component of the code individually. All components can be tested at least once. A major advantage of this approach is that it becomes easier to detect bugs early on. The small scope means it is easier to track down the cause of bugs when they occur.
PHPUnit is a unit testing framework for the PHP programming language. It is an instance of the xUnit design for unit testing systems that began with SUnit and became popular with JUnit. Even a small software development project usually takes hours of hard work.
You can run all the tests in a directory using the PHPUnit binary installed in your vendor folder. You can also run a single test by providing the path to the test file.
The speed of detecting non-working code depends on the tools used for continuous integration. Tests can be set to run either a one-time check at a certain time interval or can be run immediately in real-time to review changes. In short, unit tests help developers detect problems immediately, then fix them quickly.
PHPUnit is a beast. It's large, sometimes a little counter-intuitive, and it has it's flaws. Your code would - naturally - be intuitive, and flawless for your direct requirements. I too have often pondered if it wouldn't be a step forward to write my own testing framework, but... it's not. You can finish a rudimentary testing framework in a day, but:
There are a lot of reasons against writing your own.
Two points that @hakre didn't touch upon:
Doing pretty reporting on code coverage (visualizing how much code got executed) is not all that easy even so xDebug enables you do get going rather quickly there are a couple of edge cases and annoyances that take up quite some time to build.
PHPUnit helps you out with a nice report.
The most important thing when testing is the ability to quickly figure out what went wrong.
Building a nice diff
yourself for all the stuff in PHP (exceptions, objects, strings, xml, json, etc.) is quite time consuming
Also at some point you will want to move to a continous Integration server like Jenkins
and a testing framework like PHPUnit will already produce all the needed artifacts (junit.xml, clover.xml) that enables you to set up CI for your projects in half an hour
.
So all in all even if you don't use all the advanced features and helpers (like mocking, process isolation to test legacy code, outputBuffering, exception helpers) you get a base setup that will be able to grow with you when your project grows and get more mature.
Btw. there is a web interface to phpunit
called Visual PHPUnit
that runs in a browser. Even so, to be honest, I don't have any clue as to why anyone would want that. Maybe with out refresh but I'd rather a script loop on a cli terminal than. But to each their own :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With