Title: Test Driven Web Development
1Test Driven Web Development
- Nirav Mehta
- Linux Bangalore 2004
2Session Plan
- Introduction to test driven development
- Test driven development with PHP
- How to cope up with test driven development
- Experiences
3Test driven development says write test cases
before code!
4Test before code is actually great way to improve
code quality
5You may ask how can we do test driven development
in a web project?
- Very well suited for OO programming
- Web testing available forms, auth etc
- Automated tests fit well for repeatitive tests
- Manual testing otherwise
- UI
- Usability
- Compatibility
6PHP has two good tools available PEARPhpUnit
and SimpleTest
7SimpleTest is a set of classes that empower you
to write, run and manage your test cases
8Here's a small sample
- class CartTestCase extends UnitTestCase
- function testAddToCart()
- cart new Cart()
- result cart-gtadd(1000, 1)
- this-gtassertTrue(result, 'Item added')
-
9You can assert for true/false, data types,
equality, patterns and errors
10You can also initialize or clean up the test
environment, raise errors, pass or fail tests etc
11Let us write and run some simple test cases for
our shopping cart now
12Faking an object mock objects and server stubs
13It's easy to test web pages with simple pattern
matching and link following
14SimpleTest also allows handling simple form
submissions
15The first thing you need in your web app is
authentication, so you need a way to test and
manage it.
16Alright, this all sounds good.
17Yes, test driven development really works,
despite frictions
18TDD also fits very well with an agile development
methodology
19Get on with test driven development
20Questions?
21Thanks
- Linux Bangalore Team
- Resources
- http//www.lastcraft.com/simple_test.php
- Contact Me
- nirav_at_magnet-i.com