You need to sign in to do that
Don't have an account?
HARI KRISHNA
----------------This is the Controller Class Where i am facing Problem.---------------------
public class RerenderEx {
public contact con{set;get;}
public boolean Abool{set;get;}
public boolean Bbool{set;get;}
public RerenderEx()
{
con=new contact();
Abool=false;
Bbool=false;
}
public void saveNew() {
insert con;
con.clear();//con=new contact();
}
public void saveSec() {
insert con;
Abool=true;
}
public void EditSec() {
Abool=false;
Bbool=true;
}
public void updateSec() {
update con;
}
}
------------------------------This is the Test Class which is unable to Cover above Class .Its covering only 50%----------
@isTest
public class RerenderEx_TC
{
static testMethod void testMthd()
{
boolean Abool=false;
boolean Bbool=false;
RerenderEx r=new RerenderEx();
contact con=new contact(lastname='xxx');
r.saveNew();
insert con;
con.lastname='xyy';
update con;
r.saveSec();
r.EditSec();
r.updateSec();
}
}
Help me to resolve Unit Test
----------------This is the Controller Class Where i am facing Problem.---------------------
public class RerenderEx {
public contact con{set;get;}
public boolean Abool{set;get;}
public boolean Bbool{set;get;}
public RerenderEx()
{
con=new contact();
Abool=false;
Bbool=false;
}
public void saveNew() {
insert con;
con.clear();//con=new contact();
}
public void saveSec() {
insert con;
Abool=true;
}
public void EditSec() {
Abool=false;
Bbool=true;
}
public void updateSec() {
update con;
}
}
------------------------------This is the Test Class which is unable to Cover above Class .Its covering only 50%----------
@isTest
public class RerenderEx_TC
{
static testMethod void testMthd()
{
boolean Abool=false;
boolean Bbool=false;
RerenderEx r=new RerenderEx();
contact con=new contact(lastname='xxx');
r.saveNew();
insert con;
con.lastname='xyy';
update con;
r.saveSec();
r.EditSec();
r.updateSec();
}
}
You have created a test record in your test class, but you are inserting the controllers records.
The test cls should be like this
I dont know the logic implemented, But this should do it.
Regards,
MCS