Creating a test class for a Select Statement

无人久伴 提交于 2019-12-02 10:35:39

You just need to create a test data which will be selected by your code, because the data from Org is not available in test context. After that you have to instantiate MatchReadyImage class and validate that obj has a correct value

@isTest
private class MatchReadyImageTest {

    @isTest
    private static void test1() {
        Match_Day_Check_List__c mdckl = new Match_Day_Check_List__c(
            name = 'Everton V West Ham United Goodison Park EPL 2013-05-12';
            // other required fields 
        );
        insert mdckl;
        // you can add assertions which you want 
        System.assert((new MatchReadyImage).obj != null);
    }
}

I'm confused what's the real requirement of having this class. May be you have posted very short version of it. Anyway you can use below test class(untested) for this.

@isTest
private class TestMatchReadyImage {

    @isTest
    static testMethod void testConstructor() {
        Match_Day_Check_List__c mdckl = new Match_Day_Check_List__c()            
        mdckl.Name = 'Everton V West Ham United Goodison Park EPL 2013-05-12';
        // populate if any other fields you need to
        insert mdckl;

        // make assertions for the unit test
        System.assert((new MatchReadyImage()).obj != null);
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!