You need to sign in to do that
Don't have an account?
JoeyLen
Apex test class
I have 2 triggers, one creates a case once an opportunity reaches Closed Won and a services drop down is Yes. The other comes back and checks a Services Completed check box once the case is closed. Both triggers work fine in my sandbox and I have tested the Opportunity trigger out to 100%. I am struggling getting the second trigger to test out to 100%, stuck @ 66%.
The first trigger was easy, just needed the system to create an opportunity with certain settings and viola. To create the second trigger (which in hindsight I could have created one class to test both triggers but that is another discussion) I copied first trigger test class and then added some additional instructions but cannot get it to compile.
The trigger is below and I am getting the compile error:
"Error: Compile Error: Variable does not exist: c.Status at line 27 column 9"
I know I have made some simple mistake but being new to this I am at a loss.
public class Installed_Services_Opp_Test {
static testmethod void insertOpportunity() {
Opportunity o = new opportunity();
o.Name = 'Test';
o.Opportunity_Profile__c = 'Existing Customer';
o.LeadSource = 'VAR';
o.Are_Installed_Services_Required__c = 'Yes';
o.StageName = 'Closed Won';
o.Type = 'EMC - Mobius';
o.Amount = 100000;
o.TotalOpportunityQuantity = 20;
o.CloseDate = System.today();
o.Promised_Delivery_Date__c = System.today();
o.Go_live_date__c = System.today();
insert o;
{
list<Case> cc= new list<Case>();
c.Status = 'Closed';
c.Quantity__c = 1;
c.Origin = 'Installed Services';
insert c;
}
}
}
The first trigger was easy, just needed the system to create an opportunity with certain settings and viola. To create the second trigger (which in hindsight I could have created one class to test both triggers but that is another discussion) I copied first trigger test class and then added some additional instructions but cannot get it to compile.
The trigger is below and I am getting the compile error:
"Error: Compile Error: Variable does not exist: c.Status at line 27 column 9"
I know I have made some simple mistake but being new to this I am at a loss.
public class Installed_Services_Opp_Test {
static testmethod void insertOpportunity() {
Opportunity o = new opportunity();
o.Name = 'Test';
o.Opportunity_Profile__c = 'Existing Customer';
o.LeadSource = 'VAR';
o.Are_Installed_Services_Required__c = 'Yes';
o.StageName = 'Closed Won';
o.Type = 'EMC - Mobius';
o.Amount = 100000;
o.TotalOpportunityQuantity = 20;
o.CloseDate = System.today();
o.Promised_Delivery_Date__c = System.today();
o.Go_live_date__c = System.today();
insert o;
{
list<Case> cc= new list<Case>();
c.Status = 'Closed';
c.Quantity__c = 1;
c.Origin = 'Installed Services';
insert c;
}
}
}
case c = new case();