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

Need help with on a test class for an extension controller
This test class is only getting 33% coverage, and I know it must have something to do with this line in the controller, but I am not sure how to get this covered.
The bolded/underlined parts of the extension are what are not covered.
Here is the test class:
list_of_accountmanagement = new List<string>{'Key (WIG)','Active Project','Active Opportunity > $50K','Partner-Managed','TAM-Managed','TSE-Managed (Tech Support)','Inactive'};
The bolded/underlined parts of the extension are what are not covered.
public final Account accounts; Public MAP<String,LIST<Account>> accsBucketedByType{get;set;} public List<string> list_of_accountmanagement{get;set;} public ColumnControllerExt(ApexPages.StandardController stdController) { list_of_accountmanagement = new List<string>{'Key (WIG)','Active Project','Active Opportunity > $50K','Partner-Managed','TAM-Managed','TSE-Managed (Tech Support)','Inactive'}; accsBucketedByType = new Map<String, List<Account>>(); } public map<string,List<account>> getmap_values(){ accsBucketedByType .put('Key (WIG)' ,[Select Id,name,Opportunity_Order_Status__c,NPS_Status__c,Case_Status_Stoplight__c,MSA_Status__c,Version_Status__c,Risk_Status__c,Team_Management_Status__c,Overall_Status__c,Total_RR_Converted_to_USD__c,Account_Management_Type__c,x3re__c from Account where Account_Management_Type__c =: 'Key (WIG)'order by Name]);
Here is the test class:
@isTest private class TEST_ColumnController { static testMethod void ColumnController_test1() { Profile p = [SELECT Id FROM Profile WHERE Id='xx']; //create dummy User User u = new User(Alias = 'testcc', Email='PopulateCountry@testorg.com', EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', LocaleSidKey='en_US', Department = 'Some Department', ProfileId = p.Id, TimeZoneSidKey='America/Los_Angeles', UserName='PopulateCountry@testorg.com'); insert u; System.assert(u.Id != null); //Create dummy accounts Account acc = new Account(Name = '1',Type = 'Customer',OwnerId = u.Id); insert acc; Test.startTest(); Test.setCurrentPage(Page.MyPage); // create a new Account standard controller by passing it the account record ApexPages.StandardController controller = new ApexPages.StandardController(acc); // now pass it to the extension ColumnControllerExt stdController = new ColumnControllerExt(controller); system.assert(stdController != null); // controller has successfully been created Test.stopTest(); } }Thanks for any help.
and add this line
All Answers
List<String> loa=stdController.list_of_accountmanagement;
System.assertNotEquals(0, loa.size());
Thanks for that, I have added it to the class, but it made no difference in the coverage. I guess I was wrong on my assumption. :(
These are the lines that are not covered:
Here is the full controller code:
And the test class - I made some changes thinking I figured it out - but alas, no.
and add this line
Thank you! If you are at Dreamforce this year I would like to buy you a coffee/soda/drink. I seriously ran around hugging people.
No, Unfortunately I cannot make it to Dreamforce this year. Thank you :)