You need to sign in to do that
Don't have an account?
D.Younai
Test was Success, but test code coverage is 0%.
Hi,Community.
I have a test in the following code.
Test was Success,
But Test Code coverage is 0%.
I want to 100% test coverage.
Please tell me what to do?
@isTest public with sharing class LogACallControllerExtension { public Task task; ApexPages.Standardcontroller controller; public LogACallControllerExtension(ApexPages.StandardController controller) { this.task = (Task)controller.getRecord(); User u = [Select Id From User Where id = :UserInfo.getUserId()]; // List<Lead> lead = [Select Id,Email,Phone From Lead Where Lead.Id =:ApexPages.currentPage().getParameters().get('who_id')]; // task.WhoId = lead[0].Id; task.WhoId = ApexPages.currentPage().getParameters().get('who_id'); task.WhatId = ApexPages.currentPage().getParameters().get('what_id'); task.Status = ApexPages.currentPage().getParameters().get('tsk12'); task.OwnerId = u.Id; } public PageReference save() { Task t = new Task(); t.ownerId = task.ownerId; t.status = task.status; t.subject = task.subject; t.whoId = task.whoId; t.activityDate = task.activityDate; t.Description = task.Description; insert t; return null; } static testmethod void LogACallControllerExtension(){ Task task = new Task(); task.ownerId = '005U0000000NadXIAS'; task.status = 'Completed'; task.subject = 'Call'; task.whoId = '00QU0000002mMkw'; task.activityDate = date.parse('2012/07/18'); task.Description = 'test data'; Insert task; PageReference pageRef = Page.instask; Test.setCurrentPage(pageRef); pageRef.getParameters().put('who_id','00QU0000002mMkw'); pageRef.getParameters().put('tsk12','Completed'); ApexPages.Standardcontroller std = new ApexPages.standardcontroller(task); LogACallControllerExtension lcall = new LogACallControllerExtension(std); Task TaskL = [select Id,description,ownerId,status,subject,activitydate from Task where activitydate = :date.parse('2012/07/18')]; system.assertequals(TaskL.ownerId,'005U0000000NadXIAS'); system.assertequals(TaskL.description,'test data'); system.assertequals(TaskL.activitydate,date.parse('2012/07/18')); system.assertequals(TaskL.status,'Completed'); system.assertequals(TaskL.subject,'Call'); lcall.save(); } }
Thanks.
Hmm. I don't think you want the @istest annotation at the top of this class. It looks to me like it contains your actual code (the extension controller).
All Answers
Hmm. I don't think you want the @istest annotation at the top of this class. It looks to me like it contains your actual code (the extension controller).
Hi,
Thank you taught me.
I thought required "@istest".
Remove the "@istest", that would be test code coverage become100%.
Thanks for your help on this.