Skip to main content
added 208 characters in body
Source Link
sfdcfox
  • 501.9k
  • 21
  • 473
  • 828

I'm trying to get code coverage on my class to no avail. Any assistance would be greatly appreciated. I'm sure there is a better way to write my class but just trying to get the end user his request at this point. I've spent a couple of days fiddling with this and tried Googling many resources.

Here is my Class

global with sharing class BusinessIntelligenceFeedback {

public String BusIntId{get;set;}

public Business_Intelligence_Survey__c bif { get { if (bif == null) bif = new Business_Intelligence_Survey__c( Business_Intelligence__c = BusIntId, Survey_Results__c = 'Yes' ); return bif; } set; }

// save button is clicked public PageReference save() {

global with sharing class BusinessIntelligenceFeedback {
   
  public String BusIntId{get;set;}
    
  public Business_Intelligence_Survey__c bif {
    get {
      if (bif == null)
        bif = new Business_Intelligence_Survey__c(
        Business_Intelligence__c = BusIntId,
        Survey_Results__c = 'Yes'
        );
      return bif;
    }
    set;
  }
  
  // save button is clicked
 public PageReference save() {

    try {
      insert bif; // inserts the new record into the database
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error creating new bif.'));
      return null;
    }
        // if successfully inserted new BISurvey, then displays the thank you page.
    return Page.BusinessIntelligence_Create_Thankyou;
  }

}

}

}

Here is my Test Class

@isTest(SeeAllData=true)

private class TestBusinessIntelligenceFeedback { static testMethod void testMe(){

Business_Intelligence_Survey__c bif = new Business_Intelligence_Survey__c(); bif.Business_Intelligence__c = 'a24U00000005kkL'; bif.Survey_Results__c = 'Yes'; insert bif;

@isTest(SeeAllData=true)

private class TestBusinessIntelligenceFeedback {
    static testMethod void testMe(){

  Business_Intelligence_Survey__c bif = new Business_Intelligence_Survey__c();
        bif.Business_Intelligence__c = 'a24U00000005kkL';
        bif.Survey_Results__c = 'Yes';
        insert bif;
        
    Business_Intelligence_Survey__c testbif = [select Id, Survey_Results__c, name from Business_Intelligence_Survey__c where id =:bif.Id]; 
 
     System.debug('Status on ticket after trigger fired: ' + bif.Survey_Results__c);
 
       // Test that the trigger correctly updated the survey

       System.assertEquals('Yes', bif.Survey_Results__c);

    } 

}

}

I'm trying to get code coverage on my class to no avail. Any assistance would be greatly appreciated. I'm sure there is a better way to write my class but just trying to get the end user his request at this point. I've spent a couple of days fiddling with this and tried Googling many resources.

Here is my Class

global with sharing class BusinessIntelligenceFeedback {

public String BusIntId{get;set;}

public Business_Intelligence_Survey__c bif { get { if (bif == null) bif = new Business_Intelligence_Survey__c( Business_Intelligence__c = BusIntId, Survey_Results__c = 'Yes' ); return bif; } set; }

// save button is clicked public PageReference save() {

try {
  insert bif; // inserts the new record into the database
} catch (DMLException e) {
  ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error creating new bif.'));
  return null;
}
    // if successfully inserted new BISurvey, then displays the thank you page.
return Page.BusinessIntelligence_Create_Thankyou;

}

}

Here is my Test Class

@isTest(SeeAllData=true)

private class TestBusinessIntelligenceFeedback { static testMethod void testMe(){

Business_Intelligence_Survey__c bif = new Business_Intelligence_Survey__c(); bif.Business_Intelligence__c = 'a24U00000005kkL'; bif.Survey_Results__c = 'Yes'; insert bif;

Business_Intelligence_Survey__c testbif = [select Id, Survey_Results__c, name from Business_Intelligence_Survey__c where id =:bif.Id]; 

 System.debug('Status on ticket after trigger fired: ' + bif.Survey_Results__c);

   // Test that the trigger correctly updated the survey

   System.assertEquals('Yes', bif.Survey_Results__c);

}

}

I'm trying to get code coverage on my class to no avail. Any assistance would be greatly appreciated. I'm sure there is a better way to write my class but just trying to get the end user his request at this point. I've spent a couple of days fiddling with this and tried Googling many resources.

Here is my Class

global with sharing class BusinessIntelligenceFeedback {
   
  public String BusIntId{get;set;}
    
  public Business_Intelligence_Survey__c bif {
    get {
      if (bif == null)
        bif = new Business_Intelligence_Survey__c(
        Business_Intelligence__c = BusIntId,
        Survey_Results__c = 'Yes'
        );
      return bif;
    }
    set;
  }
  
  // save button is clicked
 public PageReference save() {

    try {
      insert bif; // inserts the new record into the database
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error creating new bif.'));
      return null;
    }
        // if successfully inserted new BISurvey, then displays the thank you page.
    return Page.BusinessIntelligence_Create_Thankyou;
  }

}

Here is my Test Class

@isTest(SeeAllData=true)

private class TestBusinessIntelligenceFeedback {
    static testMethod void testMe(){

  Business_Intelligence_Survey__c bif = new Business_Intelligence_Survey__c();
        bif.Business_Intelligence__c = 'a24U00000005kkL';
        bif.Survey_Results__c = 'Yes';
        insert bif;
        
    Business_Intelligence_Survey__c testbif = [select Id, Survey_Results__c, name from Business_Intelligence_Survey__c where id =:bif.Id]; 
 
     System.debug('Status on ticket after trigger fired: ' + bif.Survey_Results__c);
 
       // Test that the trigger correctly updated the survey

       System.assertEquals('Yes', bif.Survey_Results__c);

    } 

}
Source Link

Trying to get Code Coverage on my apex Class

I'm trying to get code coverage on my class to no avail. Any assistance would be greatly appreciated. I'm sure there is a better way to write my class but just trying to get the end user his request at this point. I've spent a couple of days fiddling with this and tried Googling many resources.

Here is my Class

global with sharing class BusinessIntelligenceFeedback {

public String BusIntId{get;set;}

public Business_Intelligence_Survey__c bif { get { if (bif == null) bif = new Business_Intelligence_Survey__c( Business_Intelligence__c = BusIntId, Survey_Results__c = 'Yes' ); return bif; } set; }

// save button is clicked public PageReference save() {

try {
  insert bif; // inserts the new record into the database
} catch (DMLException e) {
  ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error creating new bif.'));
  return null;
}
    // if successfully inserted new BISurvey, then displays the thank you page.
return Page.BusinessIntelligence_Create_Thankyou;

}

}

Here is my Test Class

@isTest(SeeAllData=true)

private class TestBusinessIntelligenceFeedback { static testMethod void testMe(){

Business_Intelligence_Survey__c bif = new Business_Intelligence_Survey__c(); bif.Business_Intelligence__c = 'a24U00000005kkL'; bif.Survey_Results__c = 'Yes'; insert bif;

Business_Intelligence_Survey__c testbif = [select Id, Survey_Results__c, name from Business_Intelligence_Survey__c where id =:bif.Id]; 

 System.debug('Status on ticket after trigger fired: ' + bif.Survey_Results__c);

   // Test that the trigger correctly updated the survey

   System.assertEquals('Yes', bif.Survey_Results__c);

}

}