deploy issue: run test pass, but when i deploy to production, it still display Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required, can anyone tell me what i miss here ?
Apex Trigger:
failed to deploy: message: "Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required"
trigger CreateNewTask10 on Lead (after insert) {
List<Task> lNewTasks = new List<Task>();
for (Integer i = 0; i < Trigger.new.size(); i++) {
if (Trigger.new[i].Comments__c !=null) {
lNewTasks.add(new Task(
ActivityDate = Date.today().addDays(7),
WhoID=Trigger.new[i].Id,
Status = 'Not Started',
type='Other',
Priority='Normal',
Subject='trigger add New Comment',
description = Trigger.new[i].Comments__c
));
}
}
insert lNewTasks;
Apex class - test and pass
@isTest
public class UnitTests_CreateNewTask10 {
static testMethod void CreateNewTask10() {
//Set up user
User u1 = [SELECT Id FROM User WHERE Alias='auser'];
test.startTest();
//Run As U1
System.RunAs(u1){
Lead l = new Lead(
FirstName='Test firstName',
LastName = 'Test LastName',
Comments__c = '18888 test comments'
);
insert l;
System.debug('Created and inserted lead');
List<Task> tasks = new List<Task>();
tasks.add(new Task(
ActivityDate = Date.today().addDays(7),
WhoId = l.Id,
Status = 'Not Started',
type='Other',
Priority='Normal',
Subject='trigger add New Comment',
Description = l.Comments__c
));
insert tasks;
System.debug('Created and inserted task');
Task Ttest = [SELECT Whoid, Description FROM Task WHERE Whoid=:l.Id Limit 1];
system.assertEquals('18888 test comments', Ttest.Description);
test.stopTest();
} //end RunAs(u1)
}
}