You need to sign in to do that
Don't have an account?
I need help with writing a Test Class
Im fairly new to apex im only just getting into it.
I have written the following but Im still trying to get my head round writing a test class and would be grateful for any assistance on doing so. Im sure ill eventually get my head round this.
I have written the following but Im still trying to get my head round writing a test class and would be grateful for any assistance on doing so. Im sure ill eventually get my head round this.
public class CaseCon { List<case> CaseCon; public List<case> getCaseCon() { CaseCon = [SELECT Account.Name, Owner.Name, CaseNumber FROM Case WHERE Urgent__c = :TRUE]; return CaseCon; } }
----------------------------------------------
@isTest(SeeAllData=false)
private class CaseConTest {
static testMethod void testCon() {
Case newCase = new Case();
newCase.Urgent__c = true;
// please add any other mandatory field
insert newCase;
//instance of class
CaseCon con = new CaseCon();
List <case >caseList = con.getCaseCon();
// assert
System.assertEquals(1, caseList.size());
}
}
------------------------------------------
Regards,
Pawan Kumar
All Answers
----------------------------------------------
@isTest(SeeAllData=false)
private class CaseConTest {
static testMethod void testCon() {
Case newCase = new Case();
newCase.Urgent__c = true;
// please add any other mandatory field
insert newCase;
//instance of class
CaseCon con = new CaseCon();
List <case >caseList = con.getCaseCon();
// assert
System.assertEquals(1, caseList.size());
}
}
------------------------------------------
Regards,
Pawan Kumar