I ran into an issue the other day where I wanted to send out an email notification as part of a trigger. The code itself was no problem but, like most days, my problems began as I tried to write the unit test. I couldn't get the required test coverage on those lines of code.
Please Salesforce.com, provide some better documentation on writing test cases. Unit tests are mandatory to deploy Apex to production but the documentation on unit testing is extremely lacking. Everyone on the message boards are screaming this lack of support.
I contacted our support development rep and he suggested moving the mail functions into their own class and then pass the required parameters to send the mail. This is what I came up with:
Here is a trigger that would fire after insert and send an email: