• Andrea_Neright
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

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

 

@isTest(SeeAllData=true)
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(); } }

 

 

 

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

 

@isTest(SeeAllData=true)
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(); } }