I am new to Salesforce. I wrote test class for below program, but it is simple. I want to make use of system.assert()
, system.assertequals()
and system.runas()
commands methods for the below test method, to better understand their use. Please help me with this by providing examples of where I should implement them into my test test class as I complete it.
APEX CLASS
public class testinterview {
public String getOutput() {
return null;
}
public string fname{set;get;}
public patient__c pt{set;get;}
public list<patient__c> pat{set;get;}
public testinterview()
{
}
public void input()
{
pt=new Patient__c();
pt.FirstName__c=fname;
insert pt;
}
public void output()
{
pat= new list<patient__c>();
pat=[select Firstname__c from Patient__c ];
}
}
TEST CLASS I HAVE WRITTEN
@isTest
private class mytest{
static testMethod void testinterviewTest() {
testinterview inter=new testinterview();
inter.input();
inter.output();
}
}