News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Avnet Labs Blog:
TDD with Zend Framework - testing controllers
November 19, 2009 @ 09:37:40

On the Avnet Labs blog today Ekerete has posted a look at test-driven design with Zend Framework applications (controllers) and PHPUnit. This is the second part of a series of articles on the topic (here's part one).

In the first part of this series we set up our Zend Framework application and specified our requirements. In this part we'll tackle the first requirement '" as a user, I want to visit the home page and see a form where I can enter my full name and email address.

The tutorial shows how to write tests to check the based index controller and how to check the email newsletter enrollment page for the correct form fields. Code snippets for the tests and the controller/forms are also included.

0 comments voice your opinion now!
ttd testdrivendesign controller zendframework


Padraic Brady's Blog:
Unit Testing One Test, One Assertion - Why It Works
February 17, 2009 @ 07:56:09

Padraic Brady has pormoted simplicity for unit testing in his latest blog post. He suggests that, for each test in your suite, you have only one assertion inside.

Obviously, a ratio of 1:1 would be perfect - but I'm sure we can accept some multiple assertions within a tolerance level. A ratio of more than 1.1:1 would indicate creeping obscurity (a signal it's time for me to intervene, refactor, and do some mutation testing for extra assurance). A ratio of 2:1 indicates a lost cause.

He notes that it probably sounds like a bad idea from the start, but he reinforces the suggestion with a bit of reasoning:

It's this notion of complexity that is often used to justify multiple assertions - if you break it down into the simple components that that complexity was built out of, multiple assertions don't have a leg to stand on (just the rare instances out of your control because they absolutely must be done).

You can see response that's been posted over on the PHP in Action blog in response to Padraic's thoughts.

1 comment voice your opinion now!
unittest assertion test reason opinion multiple phpunit tdd testdrivendesign



Community Events





Don't see your event here?
Let us know!


library framework interview deployment install symfony update package tips unittest api language release opinion zendserver introduction series podcast laravel community

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework