Edit Sept 28th 2016
Thank you all for the feedback! I have a lot of reading to do and I will be marking this as answered.
Please see...
Customer Community User (Non-Plus) Sharing Set Access not applying when Creating Case
...as it is tangentally related to this Test Class & Trigger. Assistance there will be super appreciated!
Cheers!
Original Post
Trying to learn Apex and don't understand why this test class won't produce code coverage. The trigger successfully fires on a Case insertion.
Is this test class successfully inserting a case?? Is the schema code written correctly to decipher and insert a record type ID based on its name? (DeveloperName and Name is the same in this context)
@isTest
public class TestCaseAuto {
static testMethod void insertCase() {
Case TestCase = new Case();
TestCase.AccountId = '00129000005u8V0';
TestCase.RecordTypeID = Schema.SObjectType.Case.RecordTypeInfosByName.get('Implementation').RecordTypeId;
TestCase.Status = 'New';
TestCase.Origin = 'Phone';
TestCase.Ticket_Reason__c = 'IVR';
insert TestCase;
}
}
All feedback is welcome, thanks!
try
/catch
is appropriate in a test context, usually it leads to swallowed errors that are harder to hunt down. Devendra beat me to the punch but those suggestions are really important to consider. Your test does not see organization data by default, and you should not write data-dependent tests even if it is technically an option.