If you can't read please download the document
Upload
tushar-joshi
View
2.619
Download
7
Embed Size (px)
DESCRIPTION
Introduction to PHPUnit unit testing tool for PHP presented by Tushar Joshi, Nagpur @ PHPMeet help in Nagpur on 19th June 2010
Citation preview
2. Assumptions for this presentation
3. PHP Developers 4. Knowledge of Object Oriented Programming 5. Things covered
6. Discussion about need of unit testing 7. Case for PHPUnit 8. Demonstration of working of PHPUnit (not part of slides but done side by side while presenting) 9. Things not covered
10. Installation of PHP, PHPUnit, PEAR, Xdebug, NetBeans IDE 11. Configuration of the development environment 12. Detailed usage of PHPUnit, all cases which can be tested 13. Are there any bugs?
14. There cannot be any bugs now 15. Manager believes the first time Courtesy:Sam Fraser - Smith 16. Client sends issues
17. Never thought that value will be passed to this function 18. Next time manager will be skeptical to believe easily Courtesy:cheerfulmonk 19. Introducing PHPUnit
20. To re-test the code after any modifications 21. Tool to ensure your code always work for given inputs
22. Is PHPUnit Easy?
23. Learning a tool is a skill building activity 24. Assuming you know the tool, it will save you always
25. You know PHP 26. PHPUnit Overhead?
27. No need to show test classes if not needed 28. If tool is readily available, it is a matter of habit
29. Way to prove your code works in all situations 30. Opportunity to trap hidden bugs before client finds them 31. Life Saver 32. Case for PHPUnit
33. Syntax highlighting editor with context help and intelli-sense (CTRL+SPACE) What will you choose between
34. Testing by a tool, with advanced facilities 35. Sample PHP class
36. Starting with getBalance method 37. Opportunity to think behavior of getBalance 38.
39. Result Red or Green Sample Test 40. Available Assertions 41. Using Constraints
42. This creates a constraint expectation 43. $this->assertThat checks whether the value is according to the expectation 44. Available Constraints 45. Testing Exceptions
46. To check whether exception was thrown 47. Data Providers
48. Sets of parameters for which the function must run correctly 49. Reduces effort for writing multiple test methods 50. Mock Objects and Expectations
51. $object = $this->getMock('NameOfClass'); 52. $object->expects( invocationExpectation ) ->method( methodExpectation )[->with( parameterExpectation )][->will( returnValue Expectation)] 53. Available Invocation Expectations
54. Parameters and Return Values
55. $this->equals(val) type of constraints 56. $this->onConsecutiveCalls(val, val2, val3,..)
57. Advanced Features
58. DB testing with DBUnit 59. Mocking Web services 60. Testing for console output 61. References
PHPUnit Manual
NetBeans IDE Site