This question already has an answer here:

I need to increase the code coverage to 75% for the following

public with sharing class VIPortalHeaderController {
  // Fields
  private String channel;

   * Gets the channel.
  public String getChannel() {
    return channel;

   * Initializes the controller.
  public void init() {
    Id accountId = VIUtils.getPortalAccountId();
    if (accountId != null) {
      List<Account> accounts = [SELECT ParentId, //VI_Account_Type__c,
          FROM Account
          WHERE Id = :accountId];
      if (!accounts.isEmpty()) {
        Account account = accounts.get(0);


marked as duplicate by sfdcfox, Reshma, David Reed, Pranay Jaiswal, Derek F Jan 22 at 13:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Hi Swathi. Could you provide your current test class? Or anything that you did till now? Also your class will never return any channel with getChannel because there isnt any possibility to set it as is is private variable and doesnt have any method to set it – user1974566 Jan 22 at 7:15

Browse other questions tagged or ask your own question.