Hi, this example we have show basic test class for the apex class.
Apex Class
public class TestExample1 {
public string name{set;get;}
public string branch{set;get;}
public void setData(){
name='Salesforcecodes';
branch='Hyderabad';
}
public void reset(){
name=null;
branch=null;
}
}
Test Class
@isTest
private class TestExample1Test {
static testMethod void testme(){
TestExample1 t = new TestExample1();
t.setData();
system.assertEquals('Salesforcecodes', t.name);
system.assertEquals('Hyderabad', t.branch);
t.reset();
system.assertEquals(null, t.name);
system.assertEquals(null, t.branch);
}
}