Skip to main content
Hello!

I am very new to creating apex classes, and have bumped into my first code coverage issue. 

I have created a series of very basic controllers that I use to populate pageblocktables on visualforce pages. 

Could anyone show me what a test for a class like this would look like? Example:

public class BuyerAlert{

public List<Buyer__c> listOfBuyer {get; set;}

public Buyer__c Buyer {get;set;}

public BuyerAlert() {

listOfBuyer = [Select id, name, Raw_Conversion__c, Call_Dur__c, Sold_Calls_Today__c from Buyer__c WHERE Buyer_Call_Handling_Alert__c = TRUE ORDER BY Sold_Calls_Today__c DESC];

}

}

I am totally lost here. 

Thanks, 

John
2 Antworten
  1. 25. Feb. 2015, 03:29
    Hello Jhon,

    Use this code :

    @isTest(seeAllData = false)

    public class BuyerAlertTest{

        // Unit test Method

        static testmethod void UnitTest() {

            //Create your buyer record with required field

            //Buyer__c b = new Buyer__c(Buyer_Call_Handling_Alert__c = true);

            //insert b;

            test.startTest();

                BuyerAlert ba = new BuyerAlert();

            test.stopTest();

        }   

    }

    If this answers your question then hit Like and mark it as solution!

     
0/9000