function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
David DurantDavid Durant 

APEX Code Coverage Test Class

I am having trouble with creating a test class for a trigger I just created. This is the first trigger that I have created and it functions perfectly however, I currently have 0% code coverage. I have been reading the force.com Developers Guide and SDFC99.com to try to obtain some knowledge on where  to even start with this test class but I am not even sure what to test.

Below is the apex trigger I have created.
trigger UpdateFieldValues on Case (after insert) {
        Id accessory360Id = [SELECT Id FROM Accessory__c WHERE Name='197 - 360μm FiberFlex™ Fiber' Limit 1].Id;
        Id accessoryCleaverId = [SELECT Id FROM Accessory__c WHERE Name='241 - Ceramic Fiber Cleavers (set of 3) 1” x 1”' Limit 1].Id;
        Id accessoryStripperId = [SELECT Id FROM Accessory__c WHERE Name='134 - Fiber Stripping Tool' Limit 1].Id;
     
    List<Accessory_Item__c> Accessories = new List<Accessory_Item__c>();
    for (Case c : Trigger.New) {
        if (c.Quick_Order__c == '360 Fiber') {
            Accessories.add(new Accessory_Item__c(
                            Case__c = c.Id,
                            Item__c = accessory360Id));
       } Else if
           (c.Quick_Order__c == 'Cleaver') {
            Accessories.add(new Accessory_Item__c(
                            Case__c = c.Id,
                            Item__c = accessoryCleaverId));
       } Else if
           (c.Quick_Order__c == 'Fiber Stripper'){ 
            Accessories.add(new Accessory_Item__c(
                            Case__c = c.Id,
                            Item__c = accessoryStripperId));
            }
        }
        insert Accessories;
    }
Below is what I currently have for the test class however, it is still failing while atempting to test. The Id's that I am referencing are part of the 360 fiber Id and the only account that I have in my sandbox. I have read a little bit into the system.assert is this something I am missing?
@isTest 
public class TestQuickUpdate {
    static testMethod void insertNewRecord() {
       
Case recordToCreate = new Case();
       
       recordToCreate.Origin         = 'Phone';
       recordToCreate.AccountId      = '001W000000I931R';
       recordToCreate.Site__c        = 'a0EW0000000fLBY';
       recordToCreate.Quick_Order__c = '360 Fiber';
       recordToCreate.ContactId      = '003W000000OAOFK';
       
insert recordToCreate;
    }
}

The failure message that I am getting right now is below:
User-added image

Thank you for any assistance that is provided.
David ZhuDavid Zhu
Use this as a reference.
@isTest 
public class TestQuickUpdate {
    static testMethod void insertNewRecord() {
       
	Id accessory360Id = [new Accessory__c (Name='197 - 360μm FiberFlex™ Fiber')].Id;
        Id accessoryCleaverId = [new Accessory__c (Name='241 - Ceramic Fiber Cleavers (set of 3) 1” x 1”'].Id; //may need \\" replace "
        Id accessoryStripperId = [new Accessory__c (Name='134 - Fiber Stripping Tool'].Id;
   
       Case recordToCreate1 = new Case();     
       recordToCreate1.Origin         = 'Phone';
       recordToCreate1.AccountId      = '001W000000I931R';
       recordToCreate1.Site__c        = 'a0EW0000000fLBY';
       recordToCreate1.Quick_Order__c = '360 Fiber';
       recordToCreate1.ContactId      = '003W000000OAOFK';
       
       insert recordToCreate1;


	system.assertequals(1,[select accessory_item__c where case__c = :recordtocreate1.id,item__c= :accessory360Id]);

       Case recordToCreate2 = new Case();     
       recordToCreate2.Origin         = 'Phone';
       recordToCreate2.AccountId      = '001W000000I931R';
       recordToCreate2.Site__c        = 'a0EW0000000fLBY';
       recordToCreate2.Quick_Order__c = 'Cleaver';
       recordToCreate2.ContactId      = '003W000000OAOFK';
       
       insert recordToCreate2;
	system.assertequals(1,[select accessory_item__c where case__c = :recordtocreate2.id,item__c= :accessoryCleaverId]);


       Case recordToCreate3 = new Case();     
       recordToCreate3.Origin         = 'Phone';
       recordToCreate3.AccountId      = '001W000000I931R';
       recordToCreate3.Site__c        = 'a0EW0000000fLBY';
       recordToCreate3.Quick_Order__c = 'Fiber Stripper';
       recordToCreate3.ContactId      = '003W000000OAOFK';
       
       insert recordToCreate3;
	system.assertequals(1,[select accessory_item__c where case__c = :recordtocreate3.id,item__c= :accessoryStripperId]);

    }
}