• Keith Bradley
  • NEWBIE
  • 0 Points
  • Member since 2011
  • Marketing Manager and Office Automation Expert
  • MERX

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 10
    Replies

Hi All,

 

I've written a trigger on the lead object :

 

 trigger foo  on Lead (after update)

{

  System.debug('Starting foo');

 

  if (Trigger.old[0].IsConverted == false && Trigger.new[0].IsConverted == true)

          {

 // lead is being converted do sanity check to make sure all fields are filled out if not

//  add a  Trigger.new[0].addError('missing info') to fail the conversion.


  }

}

 

running this code in the UI seems to work fine which is a good start. Now I'm trying to write my unit tests for this class however I believe that the trigger is not being fired (Test coverage of selected Apex Trigger is 0% at least 1% test coverage is required.) Also the 'Starting foo' debug message is not present in the log file. I have the log level set to finest possible.

 

Here is my first unit test method

 

static testMethod void foo_ValidateOnConvert_ValidValues() 

{

Lead myTestLead = new Lead();
myTestLead.Email = 'kbradley@merx.com';
myTestLead.LastName = 'Bradley';

 

insert myTestLead; 

 

Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(myTestLead.id);

LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);

Database.LeadConvertResult lcr = Database.convertLead(lc);

 

System.assert(lcr.isSuccess() == true);

}

 

TIA for any ideas and suggestions,

 

KJB

 

 

 

 

 

 

Hi all,

 

I've recently installed (and reinstalled) the force.com ide and have successfully connected to my sandbox, created a few triggers and test cases etc. However I am unable to get the run tests menu item to appear (Supose to be Force.com->Run Tests).

 

Looking for any ideas / sugestions

 

Regards,

 

KJB

Hi All,

 

I've written a trigger on the lead object :

 

 trigger foo  on Lead (after update)

{

  System.debug('Starting foo');

 

  if (Trigger.old[0].IsConverted == false && Trigger.new[0].IsConverted == true)

          {

 // lead is being converted do sanity check to make sure all fields are filled out if not

//  add a  Trigger.new[0].addError('missing info') to fail the conversion.


  }

}

 

running this code in the UI seems to work fine which is a good start. Now I'm trying to write my unit tests for this class however I believe that the trigger is not being fired (Test coverage of selected Apex Trigger is 0% at least 1% test coverage is required.) Also the 'Starting foo' debug message is not present in the log file. I have the log level set to finest possible.

 

Here is my first unit test method

 

static testMethod void foo_ValidateOnConvert_ValidValues() 

{

Lead myTestLead = new Lead();
myTestLead.Email = 'kbradley@merx.com';
myTestLead.LastName = 'Bradley';

 

insert myTestLead; 

 

Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(myTestLead.id);

LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);

Database.LeadConvertResult lcr = Database.convertLead(lc);

 

System.assert(lcr.isSuccess() == true);

}

 

TIA for any ideas and suggestions,

 

KJB

 

 

 

 

 

 

Hi all,

 

I've recently installed (and reinstalled) the force.com ide and have successfully connected to my sandbox, created a few triggers and test cases etc. However I am unable to get the run tests menu item to appear (Supose to be Force.com->Run Tests).

 

Looking for any ideas / sugestions

 

Regards,

 

KJB

HI, My using Metadata api, how can i get the custom report data with in my .net application. (i will give report name in my .net application, then a request will sent to salesforce org, from salesforce i need to get a zip file (which contains report metadata) with in my .net application). Can any one help me to do this.