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
Øyvind Borgersen 10Øyvind Borgersen 10 

Test class custom metadata

Hi,

I've created a simple class to retrieve several custom metadata settings. How do I create a test class for this? I've tried a couple of different variations with no luck.

public with sharing class deadlineDatesController {
    @AuraEnabled
    public static List <CustomMeta__mdt> getProdDates() {

        List < CustomMeta__mdt> prodList = [SELECT MasterLabel,
                                                             value1__c,
                                                             Value2__c

                                                       FROM CustomMeta__mdt
                                                        ]; {

            system.debug('prodList' + prodList);
            return prodList;
        }
    }
kumud thakur 20kumud thakur 20
You do not need to create custom metadata in the test class. It is store as a metadata and when you call this method in your test class then query will return the meta data values.