You need to sign in to do that
Don't have an account?
Shaun B.
Code Coverage Failing
Hi,
I am new to APEX and have modified a trigger to fit my needs, but don't know how to properly modify the test class. Could someone please help?
APEX Trigger:
Current APEX Class: (0% code coverage)
I am new to APEX and have modified a trigger to fit my needs, but don't know how to properly modify the test class. Could someone please help?
APEX Trigger:
trigger JIRATrigger on JIRA__c (after insert, after update) { for (JIRA__c j : Trigger.new) { if (Trigger.isInsert && Trigger.isAfter && j.Project__c == 'Arkham' && j.Issue_Type__c == 'Bug') { JCFS.API.createJiraIssue('10103', '10103'); } if (Trigger.isInsert && Trigger.isAfter && j.Project__c == 'Arkham' && j.Issue_Type__c == 'Story') { JCFS.API.createJiraIssue('10103', '10100'); } if (Trigger.isInsert && Trigger.isAfter && j.Project__c == 'Arkham' && j.Issue_Type__c == 'Epic') { JCFS.API.createJiraIssue('10103', '10000'); } if (Trigger.isInsert && Trigger.isAfter && j.Project__c == 'Harvey' && j.Issue_Type__c == 'Bug') { JCFS.API.createJiraIssue('10300', '10103'); } if (Trigger.isInsert && Trigger.isAfter && j.Project__c == 'Harvey' && j.Issue_Type__c == 'Story') { JCFS.API.createJiraIssue('10300', '10100'); } if (Trigger.isInsert && Trigger.isAfter && j.Project__c == 'Harvey' && j.Issue_Type__c == 'Epic') { JCFS.API.createJiraIssue('10300', '10000'); } if (Trigger.isUpdate && Trigger.isAfter) { JCFS.API.pushUpdatesToJira(); } } }
Current APEX Class: (0% code coverage)
@isTest public class JIRATriggerTest { @isTest static void caseAfterInsertTest() { JCFS.JiraTriggerTestHelper.testAfterInsert('JIRA__c'); } @isTest static void caseAfterUpdateTest() { JCFS.JiraTriggerTestHelper.testAfterUpdate('JIRA__c'); } }
Please try with this code snippet,
May be it can get compile / run error . Please let me know which error are you getting. We can do this within few steps.
Regards,
Prosenjit.
All Answers
You need to create at least one record of JIRA__c to run this trigger as this has been written for JIRA__c obejct.
Thanks
Prosenjit
Thanks for your reply. Any idea how I would do that? I'm not very good at APEX. :(
Thanks,
Shaun
To Do that i Need to know the whole object structure of this JIRA__c Object. All field names. Can you give me any screen shots or something of that object so that I can help you .
Thanks,
Prosenjit
Please try with this code snippet,
May be it can get compile / run error . Please let me know which error are you getting. We can do this within few steps.
Regards,
Prosenjit.
My question is not related to your Issue with the test coverage of your Trigger but with the Trigger itself. Seems like you are using Salesforce & JIRA Cloud Connector, too. Base on your Apex Trigger could I would like to achieve the same goal: Based on the Case Type a jira ticket should be created with the same Issue Type. My Trigger looks the same and is also executed corretly based on some checkpoints in the developer console but I can't manage to get the automatic jira ticket creation to work. Have you experienced the same issue or maybe to you have experienced some pitfalls?