Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Breakpoints and Unit Tests in PHP

Status
Not open for further replies.

alonzow

IS-IT--Management
Oct 27, 2007
9
FR
Hello,
When should you use breakpoins and when should you use Unit Tests when developing and debugging PHP application?

Can you give me an example of a PHP breakpoint.

Thanks
 
a breakpoint is a debugging process for halting code execution and allowing the developer to examine the state of the various variables etc at that time. frequently the debugger then allows line by line execution.

PHP is not naturally debug aware. there are a couple of debugging extensions to IDE's around (like Zend and xDebug). I have not found either of the quoted examples very useful.

you can 'emulate' breakpoints by footprinting your code with debug statements which dump the variables you are interested in to the screen or to a text file etc. If you _really_ want code to halt thereafter you can use exit() or die(). this is how , I believe, most developers debug their applications in php.

unit testing is also related to debugging but, imo, further down the chain towards release. For unit testing you break down your code to individual functions, methods etc and provide each of the components with a known input, where you already know the expected output. you then compare the two.

the two things you mention are complementary. You will always debug using breakpoints or visualisations for just about every application you write. Unit tests, in their formalised sense, I would not expect you to use for simple applications and even for complex variants, I would say that they are most useful in regression testing (making sure that a new version of your code is not being broken by some older libraries/functions/methods.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top