+ Start a Discussion

Testing a small Page Reference Class

I have created a queue that holds data in an object in Salesforce. I have researched others who have had some similar issues but nothing is helping so far. Here is the code for it. I am just not sure how to test it, I have have the code that i tried to test it below as well. Can anyone please help me out and not just send me to a link?

public class CreateNewExceptionFromCures{
    public String ActRecTypeID = [SELECT Name, Id, DeveloperName, SobjectType FROM RecordType where SobjectType = 'Deal_Exceptions__c' and developerName = 'retail'].Id;
    //Create method for button to pass thru
    public CreateNewExceptionFromCures(ApexPages.StandardController stdController){
        //List deal = Query id, appNum from Cure where id = id of cure page

    //Create blank method{}
    public CreateNewExceptionFromCures(){}

    //create void method to populate field
    public PageReference hello1(){
        List<Cure__c> deal = [SELECT Id, Application_Number__c, Applicant_Name__c FROM CURE__c WHERE id = :ApexPages.currentPage().getParameters().get('Id')];
     List<Opportunity> opp = [Select ID, Application_number__c From Opportunity where Application_number__c = :deal[0].Application_number__c];
     //exCat = Query for category from Exception Category with description other
     List<Exception_Category__c> exCat = [SELECT Exception_Category_Description__c, Id, Exception_Category_Code__c, Name FROM Exception_Category__c where Exception_Category_Code__c = '99'];
     //create new exception record and populate the source field = cure
     Deal_Exceptions__c d = new Deal_Exceptions__c(Opportunity__c = opp[0].ID, Source__c = 'Cure', Category__c = exCat[0].id); //opp, category and recordype is required
        System.debug('CATEGORY IS*******: '+ d.category__c);       
        insert d;         
  PageReference reference=new PageReference('https://cs20.salesforce.com/'+ d.id);
        //PageReference reference = new ApexPages.StandardController(d).view();
        return reference;

--------------------------------------------------------------------TEST CLASS----------------------------------------------

public class CreateNewExceptionFromCuresTest{
    public CreateNewExceptionFromCuresTest(){
        CreateNewExceptionFromCures ne = new CreateNewExceptionFromCures();
       system.assertEquals(page.success, ne.hello1());
        Cure__c cur = new Cure__c();
        Deal_Exceptions__c d = new Deal_Exceptions__c();
        ApexPages.StandardController std = new ApexPages.StandardController(d);
        CreateNewExceptionFromCures thecontroller1 = new CreateNewExceptionFromCures(std);
The below posts has an example of testing page reference classes which might help

None of that is an example of how i am using it though and it is not making sense.