One thing that salesforce.com is working on is providing developers with a better testing environment. Salesforce.com requires you to write test cases to deploy your code to production but sometimes the process can be painful. Given the lack of something like jUnit you have to implement your own setup and test procedures. You'll need to create all of your test records and test each scenario to ensure your code performs as expected.
Here's a small test class for a controller extension using some techniques from Jason Ouellette's book Development with the Force.com Platform. BTW... if you don't have a copy of this book, get it! It's invaluable!
I've sanitized the code for your protection but essentially the controller code involves reassigning objects with a master-detail relationship. I didn't include the actual controller but that's not what is important here. The use case is you have an master record with three detail records and you want to create a new master record and move some of the details records to the new record.
The test class involves a static initializer, a shared init method and two test methods. The static initializer runs the code to perform tasks such as setting up profiles, creating users, deleting data, etc. This is where you essentially setup your test environment. The init method is called by each test method and sets up the required data for that method plus runs any shared code. Each test method then runs different scenarios to complete your code coverage.