You need to sign in to do that
Don't have an account?
Mamadou Diallo 14
0% code coverage
Hello,
I have a controller and its test class. The code coverage is currently at 0%. I tried different scenarios but I had the same issue. I'm sharing the 2 Apex classes. There are 2 formula fields Number_Of__Employees_Summary__c and Winning_Team__c. The custom field Date_Time_Closed__c is updated by workflow when an opportunity is won or renewed.
Here is the Apex controller
Thank you for your help.
I have a controller and its test class. The code coverage is currently at 0%. I tried different scenarios but I had the same issue. I'm sharing the 2 Apex classes. There are 2 formula fields Number_Of__Employees_Summary__c and Winning_Team__c. The custom field Date_Time_Closed__c is updated by workflow when an opportunity is won or renewed.
@isTest public class MyControllerTest { static testMethod void MyController(){ Integer numAccts; Integer numOppsPerAcct; List<Account> accts = new List<Account>(); for(Integer i=0;i<numAccts;i++) { Account a = new Account(Name='TestAccount' + i, RecordTypeId = '012800000003UY8', Type = 'Prospect', Number_Of_Employees__c = 190 + i ); accts.add(a); } insert accts; List<Opportunity> opps = new List<Opportunity>(); for (Integer j=0;j<numAccts;j++) { Account acct = accts[j]; // For each account just inserted, add opportunities for (Integer k=0;k<numOppsPerAcct;k++) { opps.add(new Opportunity(Name=acct.Name + ' Opportunity ' + k, CloseDate=System.today().addMonths(1), StageName = 'Closed Won', Number_Of_Employees_From_Opp = 200 + k, AccountId=acct.Id)); } } // Insert all opportunities for all accounts. insert opps; //Populate the formula fields List<Opportunity> testOppAfterInsert = new List<Opportunity>(); testOppAfterInsert = [select Name, Owner.Name, Number_Of__Employees_Summary__c, Number_Of_Employees_From_Opp, Account.Number_Of__Employees__c, Winning_Team__c, StageName, Date_Time_Closed__c from Opportunity WHERE Id IN :opps]; } MyController xyz = new MyController(); } }
Here is the Apex controller
public with sharing class MyController{ public List<Opportunity> Records {get; set;} public MyController(){ Records = [select Name, Owner.Name, Date_Time_Closed__c, Winning_Team__c, Number_Of_Employees_Summary__c, StageName from Opportunity WHERE Number_Of_Employees_Summary > 200 AND Date_Time_Closed__c != null ORDER BY Date_Time_Closed__c DESC Limit 1 ] ; } }
Thank you for your help.
Let us know if this will help you
Again, thank you for taking your time to help me.
- I will create a new Sandbox. This will ensure that Production and the new sandbox match
- I will use your code in the sandbox to see if I'll have the same error
Can you send me an email at salesforcemd@gmail.com? I can share the real codes with you.Again I appreciate you taking your weekend to help me.