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
Amy ThroppAmy Thropp 

Test Class for classes where it is only a data definition

Hi all,

We have a problem in production because, after removing some classes that weren't in use, but were well tested, our total coverage has dropped down below 75% and now we can't add any more stuff until we work out what we need to do.

Much of our Apex is contractor-developed code for our integration with our JD Edwards ERP system.  Many of the classes installed already look like the one listed below, and are coming up with 0% code coverage. If I can work out how to hit these classes with test procedures, I'm sure I can get us back over 75% (we're at 72% now).

My question is: How do you test a class like the one listed below?


public class jdeContractPriceManagerBase {
    public class ValueObject {
        private String[] apex_schema_type_info = new String[]{'http://base.bssvfoundation.e1.oracle','false','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class MessageValueObject {
        public jdeContractPriceManagerUtil.E1MessageList e1MessageList;
        private String[] e1MessageList_type_info = new String[]{'e1MessageList','http://util.bssvfoundation.e1.oracle','E1MessageList','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://base.bssvfoundation.e1.oracle','false','false'};
        private String[] field_order_type_info = new String[]{'e1MessageList'};
    }
}

Thanks for any help you can provide.
Best Answer chosen by Amy Thropp
ShashForceShashForce
Hi Amy,

This should serve as a dummy test class for the code you provided. Please note that this is not really a best practice but only a workaround:

@istest
public class testClass{
    
    public static testmethod void test_ValueObject(){
        jdeContractPriceManagerBase.ValueObject VO = new jdeContractPriceManagerBase.ValueObject();
        system.assertnotequals(VO,null);
    }
    
    public static testmethod void test_MessageValueObject(){
        jdeContractPriceManagerBase.MessageValueObject MVO = new  jdeContractPriceManagerBase.MessageValueObject();
        system.assertnotequals(MVO,null);
    }
}

If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.

Thanks,
Shashank

All Answers

ShashForceShashForce
Hi Amy,

This should serve as a dummy test class for the code you provided. Please note that this is not really a best practice but only a workaround:

@istest
public class testClass{
    
    public static testmethod void test_ValueObject(){
        jdeContractPriceManagerBase.ValueObject VO = new jdeContractPriceManagerBase.ValueObject();
        system.assertnotequals(VO,null);
    }
    
    public static testmethod void test_MessageValueObject(){
        jdeContractPriceManagerBase.MessageValueObject MVO = new  jdeContractPriceManagerBase.MessageValueObject();
        system.assertnotequals(MVO,null);
    }
}

If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.

Thanks,
Shashank
This was selected as the best answer
Amy ThroppAmy Thropp
Thanks. Works perfectly. I expect to be over 75% coverage with a few of these added.