Is there a decent PHP unit testing framework that display the test report as a webpage and has current documentation. SimpleTest's documentation isn't reliable. Even the "Getting Started" page has errors.
I would like a simple alternative to PHPUnit that allows you to just get started writing tests quickly.
Funnily enough, yours is a combination of two questions I asked some time ago :)
https://stackoverflow.com/questions/2408860/whats-the-state-of-php-unit-testing-frameworks-in-2010 in which I lamented the complicatedness of PHPUnit, but saw the light and understood that it simply is the most serious product in PHP unit testing, and probably the most worth getting into
and "Web interface" to PHPUnit tests? in which I was shown some really nice graphical "frontends" to PHPUnit tests.
Enhance PHP has web-bases results and is very simple to install and use. It also has good documentation at http://www.enahance-php.com/
It is currently being actively developed to compete with other frameworks - it is downloadable for free from the website.
Related
I am currently doing research into which test framework I should be using for php. The two choices I have are PHPUnit and PHPSpec. I know that PHPUnit is TDD(Test driven development) and PHPSpec is BDD(Behavior driven development). However due to the lack of any real PHPSpec tutorial and limited documentation on the PHPSpec site I am unable to come to a full conclusion. My question to everyone is what are some addition similarities and differences between the two frameworks? Yes BDD and TDD are big ones but are there others? And they seem similar but no one talks about their similarities in great detail. Thank you.
PHPSpec is a SpecBDD tool more dedicated to guide you in code design rather than a testing framework.
It depends what you expect from tool and if you want to make a proper TDD/SpecBDD it's easier to use PHPSpec because it was created to help developers write readable and well designed code.
Remember that TDD/SpecBDD is not about testing all edge cases or doing whole-application-integration testing. It's about writing specifications for small units of code.
Few days ago I gave a talk on it, here you can find slides: http://www.slideshare.net/cakper/2013-0613-spug-spec-bdd-in-php I hope it will be useful to make a decision.
I do some PHP with Kohana 3 (IDE:Netbeans), and got excited about idea of writing tests for code. It sounds pretty cool thing to do, but i have few complications and worries.
Why using Kohana unittest module in browser is like 5 times faster then running tests in Netbeans or command Line ?
How could i exclude all kohana internal tests? In the PHPUnit .xml configuration file ?
Why when run any test i've got in Netbeans panel two entries for it - one with yellow triangle (it says 'file x skipped'), and entry with normal test result. I do get that double entries for every test, also those native from Kohana. I don't mind but it's strange.
All over the Web i see examples, tutorials and screencasts of PHPUnit with sample classes and methods that add two numbers or displays name or do some other trivial things. I've learnt to do those kind of assertions, but how could i test my code in Kohana? My Models are 90% ORM stuff. Controllers? How? Any 'How-tos' and examples are welcome.
I've seen in Ruby tutorial about Rspec a way to test DB by using testing enviroment Databse and rollbacks after finisning tests. Also user actions like clicking links were simulated. Is it possible with PHPUnit ?
There always has been a lot of discussion on what has to be tested and what has not to be tested. Generally my opinion is that you shouldn't test things that should work, like the database driver and connection, this has little to do with your code. Some then argue that you should be able to test it anyway, but in most environment this isn't an easy thing to do and usually a big hassle.
Generally controller actions should be tested as well as any helpers or modules you've written. Usually one uses the paradigm of a mocking framework to get around the database. The good thing about this is a gigantic speed increase in your testing. There are several PHP mocking frameworks as well I suppose.
Another great thing to keep in mind is that you also have user testing. This cannot be simulated with the kind of tests you write in kohana. For this it is interesting to look at http://seleniumhq.org/
It's probably better to split such a rambling question into multiple SO questions.
No idea. Perhaps there's an invocation overhead for NetBeans to invoke phpunit, compared to apache passing the request to PHP.
That might be possible, or you could find a way to set the following option: --exclude-group kohana
No idea sorry.
AFAIK PHPUnit can't do client-interaction tests. How to do system behaviour testing could be a question on its own.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Simple test vs PHPunit
I'm new to good practices on software development. I need to know with witch testing unit framework should I use. I have see that some people use PHPUnit and others use SimpleTest. What package should I choose for a beginner?
Best Regards,
I'm really really baffled that Simpletest still is considered an alternative to phpunit. Maybe i'm just misinformed but as far as I've seen:
PHPUnit is the standard; most frameworks use it (like Zend Framework, Cake, Agavi, even Symfony is dropping their own Framework in Symfony 2 for phpunit).
PHPUnit is integrated in every PHP IDE (Eclipse, Netbeans, Zend Stuide, PHPStorm) and works nicely.
Simpletest has an eclipse extension for PHP 5.1 (a.k.a. so old that it's on sourceforge) and nothing else.
PHPUnit works fine with every continious integration server since it outputs all standard log files for code coverage and test reports.
Simpletest does not. While this is not a big problem to start with it will bite you big time once you stop "just testing" and start developing software (Yes that statement is provocative :) Don't take it too seriously).
PHPUnit is activly mainted, stable and works great for every codebase, every scenario and every way you want to write your tests.
Simpletest is unmaintained, outdated and does not work well with PHP 5.3 (released over a year ago)
(Subjective) PHPUnit provides much nicer code coverage reports than Simpletest
With PHPUnit you also get these reports inside your IDE (Netbeans, Eclipse, ...)
I've yet to see any argument in favor of Simpletest. It's not even simpler to install since PHPUnit is available via pear:
pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit
and the "first test" looks pretty much the same.
For everything you want to test PHPUnit will have a solution and you will be able to find help pretty much anywhere (SO, #phpunit irc channel on freenode, pretty much every php developer ;) )
Please correct me if i've stated something wrong or forgot something :)
I started with SimpleTest because the learning curve didn't seem as steep. But it's not maintained, and brings up loads of warnings in PHP5.3, as well as not being able to do everything I wanted. I eventually had to switch to PHPUnit, which was a long process converting my tests. If only I'd started with PHPUnit in the first place!
SimpleTest is slightly easier to grasp, but PHPUnit is the best ( in my opinion at least ) , so if you want to start learning and using a framework, start with the one you're going to use when you'll be a master in TDD. Don't look at if it's easier or harder now , because if you start with SimpleTest for example , then you start using Zend Framework because your boss tells you so , you'll have to use PHPUnit with ZF. So think of your future , because an easy to learn framework doesn't necessarily have to be the best one , usualy the harder to grasp the better the framework .
Also have a look at their revisions , see which one is maintained better .
I found SimpleTest easy to start, and usable for my purposes. No big issues found as for now. The manual/website is a bit confusing, but with some example-searching it's enough.
Does not feel very professional, but as you're asking for beginner framework, by all means, try that one :)
Here's a good read... This uses SimpleTest and to start with this is better than PHPUnit...
Newbie's Guide to Unit testing
EDIT: to clarify - I am asking for advice on both unit testing and user interface testing.
Currently, I don't use TDD. While I am developing an application I am constantly testing what I am working on. Testing iteration could be anything from minor function changes to entire models. I try not to code too much before I test. I like instant feedback.
Of course, with experience I can see potential problems or bugs occurring as I'm coding.
BUT, after an application is complete I will usually go through the entire app on the frontend and ensure all functions are working as expected. This means literally everything. Every add/edit/delete, sort, filter, even broken links and such.
This can take a lot of time sometimes but it does ensure my work hardly ever contains bugs after deployment.
However, I'm looking for a more standard solution. What do experienced developers do? Assume for a moment I am a single developer and so do not have a testing department etc
Do you hire beta testers (no good if app is sensitive to public use)?
Is it viable to build a series of 'general' unit tests which can for example test ALL sorting, filter functions. One for testing ALL add/edit/delete functions.
Love to hear your feedback. Will be changing the way I develop based on suggestions.
Of course as David said : Unit-testing for models and helpers, of course.
and I need to add Selenium
Selenium is a robust set of tools that supports rapid development of
test automation for web-based
applications. Selenium provides a rich
set of testing functions specifically
geared to the needs of testing of a
web application. These operations are
highly flexible, allowing many options
for locating UI elements and comparing
expected test results against actual
application behavior.
which is amazing :
watch the 2 min intro
http://seleniumhq.org/movies/intro.mov
How Selenium Works
Testing with PHPUnit and Selenium
Unit-testing for models and helpers, of course.
But you can do unit-testing on "page-requests", as well. See, for example:
Content with Style - Unit testing controllers with Zend Framework
That's a step towards integration testing. But for issues of layout and visual aesthetics, you're pretty much stuck with walking-through each request with your browser.
Usually what you code works is not that the problem, very nice if you also write tests for it. The problem is that you need to test the integration of your changes every time you make commit.
If you like instant feedback,as I do, probably you should have a look at Continuous Integration.
I've started using Hudson as CI server and I am not regretting it!
I'm trying to find a project that incorporates the "best practices" that are discussed and debated on a daily basis for almost all languages but I'm trying to focus on php5.
Is there a php5 open source project that I can comb through to see working examples of project that exemplifies Units Tests, Dependency Injection and other best practices
I'm basically researching for a new large project and wanted to see a shining example project in all it's glory instead of the snippets of code that are endlessly debated. Since this project will not inherit a whole bunch of legacy code I'm really trying to get things right from the start.
It seems like you are looking for something like Zend Framework!
Check out Kohana Framework too. In fact, most of the popular frameworks have great PHP code. I can not say the same for Wordpress, osCommerce, etc. Magento seems to be OK, maybe a little over engineered.
Here are the list of few libraries which are having good php standards
Laravel - PHP Framework with tons of goodies
Guzzle - CURL library
PHPUnit - PHP Testing Framework
Carbon - DateTime handling library
Faker - For generating fake data
Many more are there, the following link will help you more
https://github.com/uhub/awesome-php