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
sfuser12sfuser12 

Cover Test class for import


Hi, 

I am not able to cover this class. Can anybody help me?

public class fileImport {
    public Blob fileBody;
    public String fileName;
    public String templateName;
    public String careProgram;
    public Date fileDate;
    public String importName;
}

Thanks!
 
Best Answer chosen by sfuser12
Maharajan CMaharajan C
Hi,

Include the constructor in class:

public class fileImport {
public Blob fileBody;
public String fileName;
public String templateName;
public String careProgram;
public Date fileDate;
public String importName;
public fileImport (){
}
}

Test Class

@isTest
private class fileImportTest {
    static testmethod void testfileimport()
    {
        fileImport fi = new fileImport();
    }
}

Thanks,
Maharajan.C

All Answers

Maharajan CMaharajan C
Hi,

Include the constructor in class:

public class fileImport {
public Blob fileBody;
public String fileName;
public String templateName;
public String careProgram;
public Date fileDate;
public String importName;
public fileImport (){
}
}

Test Class

@isTest
private class fileImportTest {
    static testmethod void testfileimport()
    {
        fileImport fi = new fileImport();
    }
}

Thanks,
Maharajan.C
This was selected as the best answer
sfuser12sfuser12
Thanks Maharajan. It worked.
Deepali KulshresthaDeepali Kulshrestha
Hi,

Greetings to you!

Constructor in Apex Programming is a code and is a special method that is invoked when an object is created from the class. Constructor has the following 
properties.
Method name will be same as Class.
Access specifier will be public.
This method will invoked only one that is at the time of creating an object.
This is used to instantiate the data members of the class.
So, use the below code in your Apex Controller.

public String importName;
}

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com