You need to sign in to do that
Don't have an account?
Mario C
Test Class not covering Class code
I've create a button to show all activities on lightining. It all works, but when I create the test class for the class, the code coverage of the class % remaing 0!
Here is the Class
and this is the test class...considering that I am still learning, I am pretty sure there is clearly something which I am missing:
Here is the Class
public class ShowAllCaseActivity { Id caseId= ApexPages.currentPage().getParameters().get('Id'); public list <task> tasklist {get;set;} public ShowAllCaseActivity(){ if(caseId !=null ){ tasklist= [select id,Status,ActivityDate,Subject,Who.Name,What.Name,Description,LastModifiedDate,Owner.Name FROM Task WHERE WhatID=:caseId OR whoId=:caseId]; } } public PageReference cancel() { PageReference ldPage = new PageReference('/'+caseId); ldPage.setRedirect(true); return ldPage; } }
and this is the test class...considering that I am still learning, I am pretty sure there is clearly something which I am missing:
@isTest public class tstViewAllActivity { static TestMethod void myShowAllCaseActivityTest() { Account acc = new Account(); acc.Name ='TestAcc'; insert acc; Contact cont = new Contact(); cont.LastName ='Test'; cont.accountId = acc.id; cont.Newsletter__c = 'false'; cont.Email = 'test@test.ukic'; cont.LeadSource = 'Email'; cont.Source_Type__c = 'Salesforce'; cont.Country_USE_ME__c = 'United Kingdom'; cont.phone = '+44712345677'; insert cont; Case caseObj = new Case(); caseObj.Case_Reason__c = 'Couple'; caseObj.Status = 'New'; insert caseObj; Task myT = new Task(); myT.Subject = 'Testme'; myT.WhoId = cont.Id; myT.WhatId = caseObj.Id; myT.Status = 'Not Started'; insert myT; } }
All Answers