+ Start a Discussion

IDE test coverage 100% but 0% in salesforce

I have a couple of triggers on the Opportunity standard object (before and after update) which send an email and do a couple of field update.


I wrote a test class using Eclipse IDE. Once I run that test class I get 100% test coverage on both the triggers, however when I deploy it into my sandbox instance I get 0% on both.


Any advice ?


Below my class


private class TestOpportunityApproval {

    static testMethod void myUnitTest() {
	Account account = new Account();
        account.name = 'Test Account';
        account.BillingCountry = 'myNewCountry';
        insert account;
        Pricebook2  standardPb = [select id, name, isActive from Pricebook2 where IsStandard = true limit 1];
        Pricebook2 pbk1 = new Pricebook2 (Name='Test Pricebook Entry 1',Description='Test Pricebook Entry 1', isActive=true);
		insert pbk1;

        Product2 prd1 = new Product2 (Name='Test Product Entry 1',Description='Test Product Entry 1',productCode = 'ABC',            isActive = true); 
insert prd1; PricebookEntry pbe1 = new PricebookEntry (Product2ID=prd1.id,Pricebook2ID=standardPb.id,UnitPrice=50, isActive=true); insert pbe1; Opportunity opp = new Opportunity (Name='Test_class',StageName='Prospecting',CloseDate=Date.today(),Pricebook2Id = pbe1.Pricebook2Id, AccountId = account.id ,Project_Type__c='eDiscovery',LeadSource='List',Type='New Customer - New Business',RejectionReason__c=null); insert opp; OpportunityLineItem lineItem1 = new OpportunityLineItem (OpportunityID=opp.id,PriceBookEntryID=pbe1.id, quantity=4, totalprice=200); insert lineItem1; test.startTest(); opp.RejectionReason__c='This is a test message'; opp.StageName='Order Obtained'; update opp; System.assertEquals(Opp.StageName,'Order Obtained'); test.stopTest(); } }




Prafull G.Prafull G.
In last release, there are few issues with Code Coverage. Check the following URL

Hope it helps.

Hi Andrea,


Did you release the following from your sandbox:


1) Trigger Class

2) Apex Class (if using a handler)

3) Test Class (Which covers the above 2)




Nothing related to my situation...