• tuaroivao nhamnhien
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hello,

I have the following Visualforce page along wiht Apex Controller and Test Class. When I run the test class the coverage for Apex Controller is 0%, any idea on how to solve this issue:

Visualforce Page:

<apex:page standardController="Bid_Summaries__c" recordSetVar="Bid_Summaries__c" extensions="BidSummariesController"> <apex:pageBlock title="Bid Summary"> <apex:slds /> <style type="text/css"> body {background-color: white;} p { font-weight: bold; } p { font-style: italic;} h1 { color: #f00; } p { background-color: #eec; } newLink { color: #f60; font-weight: bold; } </style> <apex:page lightningStylesheets="true"/> <apex:form > <apex:pageBlockTable value="{! Bid_Summaries__c }" var="b"> <apex:column value="{! b.Name }"/> <apex:column value="{! b.Original_Budget__c }"/> <apex:column value="{! b.Upgrade_Amount__c }"/> <apex:column value="{! b.Budget_incl_Upgrades__c }"/> <apex:column value="{! b.TJH_Service_Fee__c }"/> <apex:column value="{! b.Concession__c }"/> <apex:column value="{! b.Upgrade_Total__c}"/> </apex:pageBlockTable> </apex:form> </apex:pageBlock> </apex:page>

Apex Controller:

​​​​​​public class BidSummariesController {

    public BidSummariesController(ApexPages.StandardController controller) {

    }

        public List<Bid_Summaries__c> Bid {get; set;}
        public BidSummariesController(){
        List<Bid_Summaries__c> Bid= [Select Id, Selected_Option__c,Concession__c, Status__c,TJH_Service_Fee__c,
                                    Upgrade_Amount__c,Upgrade_Total__c, Original_Budget__c From Bid_Summaries__c] ;
    }
                       PageReference pageRef = Page.BidSummary1;                    
                       public list <Bid_Summaries__c> getBid(){
                                              
                       return Bid;
                       
        }
    
    }


Test Class:

@isTest 

    public class BidSummariesControllertest {
        
        private static testMethod void BidSummariesController() {
            
         test.StartTest();
            
         Bid_Summaries__c b = new Bid_Summaries__c();
         
         b.Upgrade_Amount__c     = 1000;
         b.Concession__c         = 1000;         
         b.Original_Budget__c = 100;
         b.Status__c  = 'New';
            
            Insert b;
            
         
          
           test.stopTest(); 
        PageReference pageRef = Page.BidSummary1;
        Test.setCurrentPage(pageRef);
        ApexPages.StandardController sc = new ApexPages.StandardController(b);
        
      
             
           
             
            List<Bid_Summaries__c> Bids = [Select Id, Selected_Option__c,Concession__c, Status__c,TJH_Service_Fee__c,
                                    Upgrade_Amount__c,Upgrade_Total__c, Original_Budget__c From Bid_Summaries__c ];
                    
                    Update Bids;
            
            
            
        } 
        
        List<Bid_Summaries__c> Bids = New List<Bid_Summaries__c>();
             
               
                                    
          
        }
In Candidate Object. 
If user enters the First name Field then Last name should be Mandatory. & If user enters the Last name Field then First name should be Mandatory.