You need to sign in to do that
Don't have an account?
shan876
Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required?????
I have a class and a trigger associated with the class... Now, I want to deploy it and I tested it out with a couple of accounts in sandbox where i have the trigger and class... But i keep getting the error Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required... when i try to deploy it from eclipse...
What should I do? How do you test this?
What should I do? How do you test this?
thanks
All Answers
Thank you for replying back to me...
So I have two questions:
1. What is actually System.AssertEquals?
2. For my class here how would my testmthod look like?
CLASS:
thanks
I know this is an old thread, but anyone still having this problem? I have run all tests, I'm at 87%, and when I run in Apex I get 0%.
i am getting same error in trigger , what can i do for that so kindly let me know the soution.
trigger:
trigger Sampletest on Student__c (before insert) {
Student__c[] studentsList = Trigger.new;
Set<String> emailSet = new Set<String>();
for(Student__c s : studentsList)
{
emailSet.add(s.Email__c);
} //Get list of duplicate Students
List<Student__c> duplicateStudentList = [Select s.Name, s.Email__c From Student__c s where s.Email__c IN :emailSet];
Set<String> duplicateEmailIds = new Set<String>();
for(Student__c s : duplicateStudentList)
{
duplicateEmailIds.add(s.Email__c);
}
for(Student__c s : studentsList)
{
if(duplicateEmailIds.contains(s.Email__c))
{
s.Email__c.addError('Record already exist with same email Id');
}
}
}
class:
@isTest
private with sharing class TestTriggers {
static testMethod void myUnitTest() {
Student__c s = new Student__c();
s.Name = 'Om Test';
s.l_Name__c = 'LastName';
Course__c c = new Course__c();
c.Name = 'SFDC';
c.Fees__c = 2000;
// insert c;
// s.Course__c = c.Id;
// s.Installment_1__c = 2000;
//s.Email__c = 'admin@shivasoft.in';
try
{
insert s;
}
catch(System.DMLException e)
{
System.assert(e.getMessage().contains('Record already exist with same email Id'));
}
}
}
Hi,How to delete Trigger and apex Class in salesforce Enterprise edition using Eclipse and let me know the solution of this as soon as possible.
I m getting same error
"Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required"
Here is my trigger
trigger FlightRequestTrigger on Flight_Request__c (after insert) {
List<Opportunity> listOpp = new List<Opportunity>();
boolean flag = true;
for (Flight_Request__c fr: trigger.new)
{
Opportunity oppNew = [SELECT Id,StageName FROM Opportunity WHERE Id =:fr.Opportunity__c];
if(oppNew.StageName == 'To Be Searched')
{
oppNew.StageName = 'Search';
listOpp.add(oppNew);
}
}
if (listOpp != null && !listOpp .isEmpty())
{
Database.update(listOpp);
}
}
And this is the test case
@isTest
public class FlighRequestTestCase {
private static testMethod void myUnitTest() {
Opportunity oppNew = new Opportunity();
oppNew.Name = 'Test Opp';
oppNew.StageName = 'To Be Searched';
oppNew.CloseDate = System.now().date();
insert oppNew;
Flight_Request__c fr = new Flight_Request__c();
fr.From__c ='Ani';
fr.To__c ='Ani';
fr.Opportunity__c = oppNew.Id;
insert fr;
List<Opportunity> listOpp = new List<Opportunity>();
oppNew = [SELECT Id,StageName FROM Opportunity WHERE Id =:fr.Opportunity__c];
if(oppNew.StageName == 'To Be Searched')
{
oppNew.StageName = 'Search';
listOpp.add(oppNew);
}
if (listOpp != null && !listOpp .isEmpty())
{
Database.update(listOpp);
}
}
}
Please help me, what i m doing wrong here?