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
honda57honda57 

Need help building a test class- not a developer

I have an Apex class I borrowed from the community, but I need help building a test class before I can deploy to production.  Can someone help me?  I plan on going through some tutorials, but I am in a time crunch to get this deployed.

Here is my Apex Class (it is short):

public class preChatRemoting_Con 
{
    public preChatRemoting_Con(ApexPages.StandardController controller) 
    {

    }
    @RemoteAction
    public static contact getcontact(string contactemail)
    {
        Contact testContact=new Contact();
        testContact=[Select Id,Name from Contact where email=:contactemail limit 1];
        return testContact;
    }

}
Manoj DegaManoj Dega
Hi Honda,
Pls find below test class:
@istest
public class preChatRemoting_conTest {
	static testMethod void preChatRemoting_conMethod(){
			Contact con = new Contact ();
			con.LastName = 'Test Contact';
    		con.Email = 'test@gmail.com';
    		System.debug(con);
			insert con;
			
			ApexPages.StandardController sc = new ApexPages.StandardController(con);
			preChatRemoting_Con pcr_con = new preChatRemoting_Con(sc);
    		System.debug('PCR_CON'+pcr_con);
        	String contactemail = 'test@gmail.com';
    		preChatRemoting_Con.getcontact(contactemail);
    }
}