You need to sign in to do that
Don't have an account?
Holly Havelka 10
Help with my Extension Controller Test Class
Hi everyone,
I am looking for some help with writing a test class for the below extension controller:
I am just learning Salesforce coding, so I am very shaky on writing test classes. Thanks in advance for any help or feedback.
I am looking for some help with writing a test class for the below extension controller:
/* * Extension controller for calling Breakthrough Application Settings. * * HH, Breakthrough Collaborative, 2017 */ public class ApplicationDisplayController { public Breakthrough_Application_Settings__c settings { get; set; } public Boolean isDisplayed { get; set; } public ApplicationDisplayController(MyProfileController ctrlParam) { this.settings = [select Display__c, Name from Breakthrough_Application_Settings__c where Active__c = true LIMIT 1]; this.isDisplayed = settings.Display__c; } public ApplicationDisplayController(AlumniSearchController ctrlParam) { this.settings = [select Display__c, Name from Breakthrough_Application_Settings__c where Active__c = true LIMIT 1]; this.isDisplayed = settings.Display__c; } public ApplicationDisplayController(JobBoardSearchController ctrlParam) { this.settings = [select Display__c, Name from Breakthrough_Application_Settings__c where Active__c = true LIMIT 1]; this.isDisplayed = settings.Display__c; } public ApplicationDisplayController(ResourceLibraryController ctrlParam) { this.settings = [select Display__c, Name from Breakthrough_Application_Settings__c where Active__c = true LIMIT 1]; this.isDisplayed = settings.Display__c; } }
I am just learning Salesforce coding, so I am very shaky on writing test classes. Thanks in advance for any help or feedback.
Should not be more effort then adding an extension to pages. Think that would be a better way to go without knowing your complete requirements.
All Answers
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_error_handling.htm
Then if running in to specific issues on your test class create a topic that issue with all your code.
If this answers your question please select it as Best Answer.
This is my newly constructed test class, but I am getting 'Compile Error: Constructor not defined: [MyProfileController].<Constructor>(Breakthrough_Application_Settings__c)':
This is actually no langer about how to test a controller but a totally different problem or challange.
Your assert has a small issue to, it should be in the format System.assertEquals(Expected, Actual) giving you:
I have a custom setting list that I want to be able to call on from different visualforce pages. Instead of adding in the custom setting parameter, I thought I could get away with creating the extension controller that could be easily added to each VF page.
Not sure where to go from here.
Should not be more effort then adding an extension to pages. Think that would be a better way to go without knowing your complete requirements.