You need to sign in to do that
Don't have an account?

Test class for a trigger
Hi there, I've written a trigger that sends an email based upon a new opportunity. Trigger works great. Now for the test classes. I've got this test class:
public class testEmailTrigger { //This class is simply to test the SendEmailTrigger trigger //Test Method static testMethod void testEmail { //Insert a record into the right table to test //In this case, the table is Opportunity Opportunity o = new Opportunity (); o.Amount='100'; o.CloseDate = System.Today(); o.Description = 'TEST'; //Start the test test.startTest(); insert o; test.stopTest(); } }
It complains at the line "Opportunity o = new Opportunity(); with the error "unexpected token Opportunity." What am I doing wrong?
Your method declaration is wrong:
static testMethod void testEmail() {
You need the parentheses after testEmail. Also, you'll have a problem trying to set amount = '100', it will give you illegal assignment from String to Decimal.
All Answers
Your method declaration is wrong:
static testMethod void testEmail() {
You need the parentheses after testEmail. Also, you'll have a problem trying to set amount = '100', it will give you illegal assignment from String to Decimal.
Actually, this trigger is for accounts/contacts that already exist.
Thanks!