tests before writing code. • TDD are continuous short cycle of test, code, refactor. • Test cases are in separate files. No more print_r & var_dump in your code! • The tests contain assertions that are either true or false. Passing the tests confirms correct behavior of the code. Tuesday, May 22, 12
code is doing what it's suppose to. • Small wins makes the coding process more enjoyable (Gamification). • Working code every step of the way! Tuesday, May 22, 12
necessary to pass tests, designs can be cleaner and clearer than is often achieved by other methods. • Resist the urge to pre-optimize the code. Just make it pass first. • Too many asserts might be a sign that your function is doing too many things - break it into smaller chunks. • No code is perfect. Tuesday, May 22, 12
breaks, it's isolated and easily traceable. • Testable units speed up development - Update the test case, make the code change, run the tests. • Confidence in making larger change sets. Tuesday, May 22, 12
affected by the latest code change. • Coverage reports help you discover potential weak spots / blind spots in your code. • Tests with examples will help in simulating actual use cases in an automated manner. • Tests becomes the documentation. Tuesday, May 22, 12
have a tendency to take shortcuts by writing conservative test cases. • One way to prevent this is to pair-program with another developer or a product owner when preparing the test cases. • Spec documents that includes examples can be useful to validate code behavior. Tuesday, May 22, 12
PHP projects. It provides both a framework that makes the writing of tests easy as well as the functionality to easily run the tests and analyse their results. • http://phpunit.de • Created by Sebastian Bergmann Tuesday, May 22, 12
but testing the codes as a user would use your app (ie. how diff parts of your code work together). • Process is the same, just that the tests are story-based. • User stories = Specs with examples Tuesday, May 22, 12
• Read: Downtime of at least 1-2 days • Nothing is full-proof! • It's easy to get lured into a false sense of security. • Even if u have 100% coverage, it still doesn't prevent unintended usage from breaking the code. • Bugs are test cases you have not written yet. Tuesday, May 22, 12