• Rals Chadda
  • NEWBIE
  • 15 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
extension class is giving only 33% code coverage .Any help how to can I cover these lines ??

the following two lines are not covered in test class
public List<Opportunity> getdemo() {
        return [Select Name , Account.name , StageName from Opportunity];

here is the test class which i m using
@isTest
Public class DemoTable2Test {
 static testmethod void testDemoTable2(){
 
  Opportunity oppy = new opportunity();
  oppy.name='ABC';
  oppy.StageName='abc';
  oppy.CloseDate=System.today();
  insert oppy;
  
  ApexPages.StandardController controller = new ApexPages.standardController(oppy);
  DemoTable2 e = new DemoTable2(controller );


  //Test converage for the myPage visualforce page
  PageReference pageref = Page.DemoTable2;
  Test.setCurrentPageReference(pageref);
  ApexPages.currentPage().getParameters().put('Id', oppy.Id);
  


 }
}

extension
 
public class DemoTable2 {
    //public  Opportunity oppty {get;set;}
    public DemoTable2(ApexPages.StandardController controller) {
    //this.oppty = (Opportunity)controller.getRecord();
    
    }
  
    public List<Opportunity> getdemo() {
        return [Select Name , Account.name , StageName from Opportunity];
    }

}

page
<apex:page standardController="opportunity" extensions="DemoTable2">
    <apex:pagemessages />
    <html lang="en">
        <head>
            <meta charset="utf-8"/>
            <meta name="viewport" content="width=device-width, initial-scale=1"/>
            <apex:stylesheet value="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"/>
            <!--<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">-->
            <apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"/>
            <!--- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>-->
            <apex:includeScript value="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"/>
            <!---<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>-->
        </head>
        <apex:form >
            <apex:pageBlock id="here">
                <body>
                    <div class="container">
                        <br></br>
                        <!-- Trigger the modal with a button -->
                        <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal" style="margin-left: 45%;margin-right: 60%;">Create Opportunity</button>
                            <br></br><br></br>
   
                            <!-- <br></br>Modal -->
                            <div class="modal fade" id="myModal" role="dialog">
                                <div class="modal-dialog">
       
                                <!-- Modal content-->
                                    <div class="modal-content">
                                    <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                                            <h4 class="modal-title">Create New Opportunity</h4>
                                    </div>
                                    <div class="modal-body" >
                                        <table class="table">
                                            <tr>
                                                <td>Name</td> 
                                                <td><apex:inputField value="{! Opportunity.Name}" required="true"/></td>
                                            </tr>   
                                            <tr>
                                                <td>Account </td> 
                                                <td><apex:inputField value="{! Opportunity.Accountid}" required="true"/></td>
                                            </tr> 
                                            <tr>
                                                <td>Close Date</td> 
                                                <td><apex:inputField value="{! Opportunity.CloseDate}"/></td>
                                            </tr>  
                                            <tr>
                                                <td>Stage Name</td> 
                                                <td><apex:inputField value="{! Opportunity.StageName}"/></td>
                                            </tr>   
                                        </table>
                                    </div>
                                    <div class="modal-footer">
                                        <apex:commandButton value="Cancel"/>&nbsp;&nbsp;&nbsp;
                                        <apex:commandButton value="Save"  action="{!save}" rerender="here" />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!---- Table--->
                    <div class="panel panel-default" style="margin-left: 20%;margin-right: 20%;">
                        <div class="panel-heading">
                            <table width="100%" cellpadding ="1" cellspacing = "1">
                                <tr>
                                    <th>#</th>
                                    <th>Opportunity Name</th>
                                    <th> Account Name </th>
                                    <th>Stage</th>
                                </tr>
                                <apex:variable var="i" value="{!1}"/>
                                <apex:repeat value="{!demo}" var="item">
                                    <tr>
                                        <td>{!i}<apex:variable var="i" value="{!i+1}"/></td>
                                        <td><apex:outputText value="{!item.Name}" /></td>
                                        <td><apex:outputText value="{!item.Account.name}"/></td>
                                        <td><apex:outputText value="{!item.StageName}"/></td>
                                    </tr>        
                                </apex:repeat>
                            </table>
                        </div >
                    </div>
                </body> 
            </apex:pageBlock>
        </apex:form>
    </html>
</apex:page>

 

Hi my extension class is giving only 50% code coverage .Any help how to cover this

the following two lines are not covered in test class
 

public List<Opportunity> getdemo() {
        return [Select Name , Account.name , StageName from Opportunity];

Test class
@isTest
Public class DemoTable2Test {
 static testmethod void testDemoTable2(){
 
  Opportunity oppy = new opportunity();
  oppy.name='ABC';
  oppy.StageName='abc';
  oppy.CloseDate=System.today();
  insert oppy;
  
  DemoTable2 controller = new DemoTable2(new ApexPages.StandardController(oppy));
  //Test converage for the myPage visualforce page
  PageReference pageref = Page.DemoTable2;
  Test.setCurrentPageReference(pageref);
  ApexPages.currentPage().getParameters().put('Id', oppy.Id);
  
  // create an instance of the controller
 DemoTable2 dm = new DemoTable2();

 }
}

extension
public class DemoTable2 {
 
    public DemoTable2(ApexPages.StandardController controller) {

    
    }
   public DemoTable2()
   {}
    public List<Opportunity> getdemo() {
        return [Select Name , Account.name , StageName from Opportunity];
    }

}

page
<apex:page standardController="opportunity" extensions="DemoTable2">
    <apex:pagemessages />
    <html lang="en">
        <head>
            <meta charset="utf-8"/>
            <meta name="viewport" content="width=device-width, initial-scale=1"/>
            <apex:stylesheet value="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"/>
            <!--<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">-->
            <apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"/>
            <!--- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>-->
            <apex:includeScript value="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"/>
            <!---<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>-->
        </head>
        <apex:form >
            <apex:pageBlock id="here">
                <body>
                    <div class="container">
                        <br></br>
                        <!-- Trigger the modal with a button -->
                        <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal" style="margin-left: 45%;margin-right: 60%;">Create Opportunity</button>
                            <br></br><br></br>
   
                            <!-- <br></br>Modal -->
                            <div class="modal fade" id="myModal" role="dialog">
                                <div class="modal-dialog">
       
                                <!-- Modal content-->
                                    <div class="modal-content">
                                    <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                                            <h4 class="modal-title">Create New Opportunity</h4>
                                    </div>
                                    <div class="modal-body" >
                                        <table class="table">
                                            <tr>
                                                <td>Name</td> 
                                                <td><apex:inputField value="{! Opportunity.Name}" required="true"/></td>
                                            </tr>   
                                            <tr>
                                                <td>Account </td> 
                                                <td><apex:inputField value="{! Opportunity.Accountid}" required="true"/></td>
                                            </tr> 
                                            <tr>
                                                <td>Close Date</td> 
                                                <td><apex:inputField value="{! Opportunity.CloseDate}"/></td>
                                            </tr>  
                                            <tr>
                                                <td>Stage Name</td> 
                                                <td><apex:inputField value="{! Opportunity.StageName}"/></td>
                                            </tr>   
                                        </table>
                                    </div>
                                    <div class="modal-footer">
                                        <apex:commandButton value="Cancel"/>&nbsp;&nbsp;&nbsp;
                                        <apex:commandButton value="Save"  action="{!save}" rerender="here" />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!---- Table--->
                    <div class="panel panel-default" style="margin-left: 20%;margin-right: 20%;">
                        <div class="panel-heading">
                            <table width="100%" cellpadding ="1" cellspacing = "1">
                                <tr>
                                    <th>#</th>
                                    <th>Opportunity Name</th>
                                    <th> Account Name </th>
                                    <th>Stage</th>
                                </tr>
                                <apex:variable var="i" value="{!1}"/>
                                <apex:repeat value="{!demo}" var="item">
                                    <tr>
                                        <td>{!i}<apex:variable var="i" value="{!i+1}"/></td>
                                        <td><apex:outputText value="{!item.Name}" /></td>
                                        <td><apex:outputText value="{!item.Account.name}"/></td>
                                        <td><apex:outputText value="{!item.StageName}"/></td>
                                    </tr>        
                                </apex:repeat>
                            </table>
                        </div >
                    </div>
                </body> 
            </apex:pageBlock>
        </apex:form>
    </html>
</apex:page>

 

HI ,

i want to use bootstrap modal which on click of custom button "Open modal", itshould open a pop - up ..

i used this code from repositorm bt when i click on button "Open Modal" the pop up dosent work, nothing happens .

any help ?

<apex:page >

<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
 <apex:stylesheet value="{!URLFOR($Resource.bootstrap, 'bootstrap-3.2.0-dist/css/bootstrap.min.css')}"/>
  <apex:includeScript value="{!URLFOR($Resource.bootstrap, 'bootstrap-3.2.0-dist/js/bootstrap.js')}"/> 
    <apex:includeScript value="{!URLFOR($Resource.bootstrap, 'bootstrap-3.2.0-dist/js/bootstrap.min.js')}"/> 
</head>
<body>

<div class="container">
  <h2>Modal Example</h2>
  <!-- Trigger the modal with a button -->
  <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
          <p>Some text in the modal.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
      
    </div>
  </div>
  
</div>

</body>
</html>
</apex:page>

Hi my extension class is giving only 50% code coverage .Any help how to cover this

the following two lines are not covered in test class
 

public List<Opportunity> getdemo() {
        return [Select Name , Account.name , StageName from Opportunity];

Test class
@isTest
Public class DemoTable2Test {
 static testmethod void testDemoTable2(){
 
  Opportunity oppy = new opportunity();
  oppy.name='ABC';
  oppy.StageName='abc';
  oppy.CloseDate=System.today();
  insert oppy;
  
  DemoTable2 controller = new DemoTable2(new ApexPages.StandardController(oppy));
  //Test converage for the myPage visualforce page
  PageReference pageref = Page.DemoTable2;
  Test.setCurrentPageReference(pageref);
  ApexPages.currentPage().getParameters().put('Id', oppy.Id);
  
  // create an instance of the controller
 DemoTable2 dm = new DemoTable2();

 }
}

extension
public class DemoTable2 {
 
    public DemoTable2(ApexPages.StandardController controller) {

    
    }
   public DemoTable2()
   {}
    public List<Opportunity> getdemo() {
        return [Select Name , Account.name , StageName from Opportunity];
    }

}

page
<apex:page standardController="opportunity" extensions="DemoTable2">
    <apex:pagemessages />
    <html lang="en">
        <head>
            <meta charset="utf-8"/>
            <meta name="viewport" content="width=device-width, initial-scale=1"/>
            <apex:stylesheet value="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"/>
            <!--<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">-->
            <apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"/>
            <!--- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>-->
            <apex:includeScript value="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"/>
            <!---<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>-->
        </head>
        <apex:form >
            <apex:pageBlock id="here">
                <body>
                    <div class="container">
                        <br></br>
                        <!-- Trigger the modal with a button -->
                        <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal" style="margin-left: 45%;margin-right: 60%;">Create Opportunity</button>
                            <br></br><br></br>
   
                            <!-- <br></br>Modal -->
                            <div class="modal fade" id="myModal" role="dialog">
                                <div class="modal-dialog">
       
                                <!-- Modal content-->
                                    <div class="modal-content">
                                    <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                                            <h4 class="modal-title">Create New Opportunity</h4>
                                    </div>
                                    <div class="modal-body" >
                                        <table class="table">
                                            <tr>
                                                <td>Name</td> 
                                                <td><apex:inputField value="{! Opportunity.Name}" required="true"/></td>
                                            </tr>   
                                            <tr>
                                                <td>Account </td> 
                                                <td><apex:inputField value="{! Opportunity.Accountid}" required="true"/></td>
                                            </tr> 
                                            <tr>
                                                <td>Close Date</td> 
                                                <td><apex:inputField value="{! Opportunity.CloseDate}"/></td>
                                            </tr>  
                                            <tr>
                                                <td>Stage Name</td> 
                                                <td><apex:inputField value="{! Opportunity.StageName}"/></td>
                                            </tr>   
                                        </table>
                                    </div>
                                    <div class="modal-footer">
                                        <apex:commandButton value="Cancel"/>&nbsp;&nbsp;&nbsp;
                                        <apex:commandButton value="Save"  action="{!save}" rerender="here" />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!---- Table--->
                    <div class="panel panel-default" style="margin-left: 20%;margin-right: 20%;">
                        <div class="panel-heading">
                            <table width="100%" cellpadding ="1" cellspacing = "1">
                                <tr>
                                    <th>#</th>
                                    <th>Opportunity Name</th>
                                    <th> Account Name </th>
                                    <th>Stage</th>
                                </tr>
                                <apex:variable var="i" value="{!1}"/>
                                <apex:repeat value="{!demo}" var="item">
                                    <tr>
                                        <td>{!i}<apex:variable var="i" value="{!i+1}"/></td>
                                        <td><apex:outputText value="{!item.Name}" /></td>
                                        <td><apex:outputText value="{!item.Account.name}"/></td>
                                        <td><apex:outputText value="{!item.StageName}"/></td>
                                    </tr>        
                                </apex:repeat>
                            </table>
                        </div >
                    </div>
                </body> 
            </apex:pageBlock>
        </apex:form>
    </html>
</apex:page>

 

HI ,

i want to use bootstrap modal which on click of custom button "Open modal", itshould open a pop - up ..

i used this code from repositorm bt when i click on button "Open Modal" the pop up dosent work, nothing happens .

any help ?

<apex:page >

<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
 <apex:stylesheet value="{!URLFOR($Resource.bootstrap, 'bootstrap-3.2.0-dist/css/bootstrap.min.css')}"/>
  <apex:includeScript value="{!URLFOR($Resource.bootstrap, 'bootstrap-3.2.0-dist/js/bootstrap.js')}"/> 
    <apex:includeScript value="{!URLFOR($Resource.bootstrap, 'bootstrap-3.2.0-dist/js/bootstrap.min.js')}"/> 
</head>
<body>

<div class="container">
  <h2>Modal Example</h2>
  <!-- Trigger the modal with a button -->
  <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
          <p>Some text in the modal.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
      
    </div>
  </div>
  
</div>

</body>
</html>
</apex:page>