+ Start a Discussion
TechSteveTechSteve 

Testing vf pages list fails.

HI all, I am writing the test class for a page that checks a list of records and shows the newest 1 on the page.

It is giving me the coverage I need but failing the Highlighted test and I just can't find the reason.

PLEASE  Could anyone offer any sugguestions:-

 

Public static TestMethod void getSF36info()
    {
         
    // this builds the constructor for the controller which links this to the correct object
            SF36__c testrev = new SF36__c(SF36Client__c = '003R000000Y7Gw4',
                HQ10a1__c = True,HQ10a2__c = False,HQ10a3__c = False,HQ10a4__c = False,HQ10a5__c = False,
                HQ11a1__c = False,HQ11a2__c = True,HQ11a3__c = False,HQ11a4__c = False,HQ11a5__c = False,
                HQ11b1__c = False,HQ11b2__c = False,HQ11b3__c = True,HQ11b4__c = False,HQ11b5__c = False,
                HQ11c1__c = False,HQ11c2__c = False,HQ11c3__c = False,HQ11c4__c = True,HQ11c5__c = False,
                HQ11d1__c = False,HQ11d2__c = False,HQ11d3__c = False,HQ11d4__c = False,HQ11d5__c = True,
                HQ1a1__c = False,HQ1a2__c = True,HQ1a3__c = False,HQ1a4__c = False,HQ1a5__c = False);
                Insert testrev;

            ApexPages.StandardController stdController = new ApexPages.StandardController(testrev);
            SF36Ext SF = new SF36Ext(stdController);
         
              // **** build a test list *****
            List<SF36__c> Reviews = new List<SF36__c>{};
            for (Integer i = 0; i < 10; i++) {
                SF36__c revs = new SF36__c(SF36Client__c = '003R000000Y7Gw4' + i,
                HQ10a1__c = True,HQ10a2__c = False,HQ10a3__c = False,HQ10a4__c = False,HQ10a5__c = False,
                HQ11a1__c = False,HQ11a2__c = True,HQ11a3__c = False,HQ11a4__c = False,HQ11a5__c = False,
                HQ11b1__c = False,HQ11b2__c = False,HQ11b3__c = True,HQ11b4__c = False,HQ11b5__c = False,
                HQ11c1__c = False,HQ11c2__c = False,HQ11c3__c = False,HQ11c4__c = True,HQ11c5__c = False,
                HQ11d1__c = False,HQ11d2__c = False,HQ11d3__c = False,HQ11d4__c = False,HQ11d5__c = True,
                HQ1a1__c = False,HQ1a2__c = True,HQ1a3__c = False,HQ1a4__c = False,HQ1a5__c = False);
                Reviews.add(revs);
                }
            System.debug('Inserting list detail');
                insert Reviews;
            System.assertEquals(Reviews.size()>5, true); // List has multiple records
            System.assert(SF36__c.HQ10a3__c != null); // field has data
           
                  // **** Extract a record ***
            for(SF36__c tr:[SELECT name,SF36Client__c,
                HQ10a1__c,HQ10a2__c,HQ10a3__c,HQ10a4__c,HQ10a5__c,HQ11a1__c,HQ11a2__c,HQ11a3__c,HQ11a4__c,
                HQ11a5__c,HQ11b1__c,HQ11b2__c,HQ11b3__c,HQ11b4__c,HQ11b5__c,HQ11c1__c,HQ11c2__c,HQ11c3__c,
                HQ11c4__c,HQ11c5__c,HQ11d1__c,HQ11d2__c,HQ11d3__c,HQ11d4__c,HQ11d5__c,HQ1a1__c,HQ1a2__c,
                HQ1a3__c,HQ1a4__c,HQ1a5__c
                FROM SF36__c
                WHERE CreatedDate = TODAY and SF36Client__c = '003R000000Y7Gw44'
                ORDER By name DESC LIMIT 1]){
                testFalse = tr.HQ11c1__c; testTrue = tr.HQ11c4__c;}
               // **** test it has data ****
            System.assertEquals(testFalse, False);
            System.assertEquals(testTrue, True); 
           
            System.debug('list test if an old record exists no rid');
            List<SF36__c> revs = SF.getSF36info();
                system.assert(revs.size()>0);
    } 

 

****** Controller ******

    public ApexPages.StandardSetController setar {
        get {
        if (ApexPages.currentPage().getParameters().get('rid') == null) { // if no record number is in url open the newest one *******
            if(setar == null) {
                setar = new ApexPages.StandardSetController(Database.getQueryLocator(
                    [SELECT name,HQ10a1__c,HQ10a2__c,HQ10a3__c,HQ10a4__c,HQ10a5__c,HQ11a1__c,HQ11a2__c,HQ11a3__c,HQ11a4__c,

HQ11a5__c,HQ11b1__c,HQ11b2__c,HQ11b3__c,HQ11b4__c,HQ11b5__c,HQ11c1__c,HQ11c2__c,HQ11c3__c,

HQ11c4__c,HQ11c5__c,HQ11d1__c,HQ11d2__c,HQ11d3__c,HQ11d4__c,HQ11d5__c,HQ1a1__c,HQ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c,HQ9h3__c,HQ9h4__c,HQ9h5__c,HQ9h6__c,HQ9i1__c,HQ9i2__c,HQ9i3__c,HQ9i4__c,HQ9i5__c,

HQ9i6__c,SF36Client__c,CreatedByid,CreatedDate
                    From SF36__c
            // find only records for the client you have picked, sort with Order By newest first then limit output to 1(show only last record).
                    Where SF36Client__c = :ApexPages.currentPage().getParameters().get('cid') Order By name DESC Limit 1]));
            }
            return setar;
          
        } else {         // if record number (rid) is in url load that record into page ************  
            if(setar == null) {          
                setar = new ApexPages.StandardSetController(Database.getQueryLocator(
                        [SELECT name,HQ10a1__c,HQ10a2__c,HQ10a3__c,HQ10a4__c,HQ10a5__c,HQ11a1__c,HQ11a2__c,HQ11a3__c,HQ11a4__c,

HQ11a5__c,HQ11b1__c,HQ11b2__c,HQ11b3__c,HQ11b4__c,HQ11b5__c,HQ11c1__c,HQ11c2__c,HQ11c3__c,

HQ11c4__c,HQ11c5__c,HQ11d1__c,HQ11d2__c,HQ11d3__c,HQ11d4__c,HQ11d5__c,HQ1a1__c,HQ1a2__c,HQ1a3__c,

HQ1a4__c,HQ1a5__c,HQ2a1__c,HQ2a2__c,HQ2a3__c,HQ2a4__c,HQ2a5__c,HQ3a1__c,HQ3a2__c,HQ3a3__c,HQ3b1__c,

HQ3b2__c,HQ3b3__c,HQ3c1__c,HQ3c2__c,HQ3c3__c,HQ3d1__c,HQ3d2__c,HQ3d3__c,HQ3e1__c,HQ3e2__c,HQ3e3__c,

HQ3f1__c,HQ3f2__c,HQ3f3__c,HQ3g1__c,HQ3g2__c,HQ3g3__c,HQ3h1__c,HQ3h2__c,HQ3h3__c,HQ3i1__c,HQ3i2__c,

HQ3i3__c,HQ3j1__c,HQ3j2__c,HQ3j3__c,HQ4a1__c,HQ4a2__c,HQ4b1__c,HQ4b2__c,HQ4c1__c,HQ4c2__c,HQ4d1__c,

HQ4d2__c,HQ5a1__c,HQ5a2__c,HQ5b1__c,HQ5b2__c,HQ5c1__c,HQ5c2__c,HQ6a1__c,HQ6a2__c,HQ6a3__c,HQ6a4__c,

HQ6a5__c,HQ7a1__c,HQ7a2__c,HQ7a3__c,HQ7a4__c,HQ7a5__c,HQ7a6__c,HQ8a1__c,HQ8a2__c,HQ8a3__c,HQ8a4__c,

HQ8a5__c,HQ9a1__c,HQ9a2__c,HQ9a3__c,HQ9a4__c,HQ9a5__c,HQ9a6__c,HQ9b1__c,HQ9b2__c,HQ9b3__c,HQ9b4__c,

HQ9b5__c,HQ9b6__c,HQ9c1__c,HQ9c2__c,HQ9c3__c,HQ9c4__c,HQ9c5__c,HQ9c6__c,HQ9d1__c,HQ9d2__c,HQ9d3__c,

HQ9d4__c,HQ9d5__c,HQ9d6__c,HQ9e1__c,HQ9e2__c,HQ9e3__c,HQ9e4__c,HQ9e5__c,HQ9e6__c,HQ9f1__c,HQ9f2__c,

HQ9f3__c,HQ9f4__c,HQ9f5__c,HQ9f6__c,HQ9g1__c,HQ9g2__c,HQ9g3__c,HQ9g4__c,HQ9g5__c,HQ9g6__c,           HQ9h1__c,HQ9h2__c,HQ9h3__c,HQ9h4__c,HQ9h5__c,HQ9h6__c,HQ9i1__c,HQ9i2__c,HQ9i3__c,HQ9i4__c,HQ9i5__c,

HQ9i6__c,SF36Client__c,CreatedByid,CreatedDate
                    From SF36__c
                // find only records for the client you have picked, sort with Order By newest first then limit output to 1(show only last record).
                    Where SF36Client__c = :ApexPages.currentPage().getParameters().get('cid')
                    AND SF36__c.name = :ApexPages.currentPage().getParameters().get('rid')]));                      
            }
            return setar;
        }}
        set;
    }

    // Initialize setar and return a list of records read by the SWA call and the field name you want to see..
  
    public List<SF36__c> getSF36info() {
         return (List<SF36__c>) setar.getRecords();
    }

joshbirkjoshbirk

Which assert specifically is failing?