• Mecrin Luvis 10
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 7
    Replies
Hi All ,

My Apex Class is

public  class TestPage {

   public String password { get; set; }
    public String username { get; set; }
    
      public PageReference login() 
      {
      
      if (username == 'mecrin' && password=='12345')

      {
        PageReference newPage = new PageReference('/apex/ThankYou');
        newPage.setRedirect(true);
        
        return newPage;
       }
    
    
    else
    {

    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter value'));

    return null;
    }


   
   }
}


 Test Class is:

@isTest
public class test1
{
public static testMethod void testExample()
{
      String password;
       String username;
    TestPage tp=new TestPage();
    tp.login();
}
}

code coverage is only 55%. I have to make it Atleast 75%.
 
Hi Guys,

I have created VF page and Apex class for Login Page. I want to write a test class for that login page.Please help .
VF Page:
<apex:page showHeader="false" controller="TestPage">

  <center>
  <apex:form >
  <apex:panelGrid >
  <apex:pageBlock title="LoginPage" >
  <apex:pageMessages id="msg"></apex:pageMessages>

  <apex:pageBlockSection >
 <p><b>UserName</b><br /><apex:inputText required="true" id="username" value="{!username}"/></p>
  <p><b>Password</b><br/><apex:inputSecret id="password" value="{!password}" /><br/></p>
              
  </apex:pageBlockSection>
  <apex:pageBlockButtons location="bottom"><apex:commandButton action="{!login}" value="login" id="login"/></apex:pageBlockButtons>
  </apex:pageBlock></apex:panelGrid>
  </apex:form>
  </center>
</apex:page>


Apex Class:
public  class TestPage {

   public String password { get; set; }
    public String username { get; set; }
    
      public PageReference login() 
      {
      
      if (username == null)

      {
        PageReference newPage = new PageReference('/apex/ThankYou');
        newPage.setRedirect(true);
        
        return newPage;
       }
    
    
    else
    {

    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter value'));

    return null;
    }


   
   }
}


I want to write a test class for that login Page. I dont know how to write test class.Please help me to reach out to that target.


Regards,
M.D.Luvis.
Hi Guys,
I am getting problems  in fusion charts. I am unable  to understand the actuall path. how to use ,where to use in salesforce. Please help to come out from this problem.

Regards,
Mecrin.
Hi All ,

My Apex Class is

public  class TestPage {

   public String password { get; set; }
    public String username { get; set; }
    
      public PageReference login() 
      {
      
      if (username == 'mecrin' && password=='12345')

      {
        PageReference newPage = new PageReference('/apex/ThankYou');
        newPage.setRedirect(true);
        
        return newPage;
       }
    
    
    else
    {

    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter value'));

    return null;
    }


   
   }
}


 Test Class is:

@isTest
public class test1
{
public static testMethod void testExample()
{
      String password;
       String username;
    TestPage tp=new TestPage();
    tp.login();
}
}

code coverage is only 55%. I have to make it Atleast 75%.
 
Hi Guys,

I have created VF page and Apex class for Login Page. I want to write a test class for that login page.Please help .
VF Page:
<apex:page showHeader="false" controller="TestPage">

  <center>
  <apex:form >
  <apex:panelGrid >
  <apex:pageBlock title="LoginPage" >
  <apex:pageMessages id="msg"></apex:pageMessages>

  <apex:pageBlockSection >
 <p><b>UserName</b><br /><apex:inputText required="true" id="username" value="{!username}"/></p>
  <p><b>Password</b><br/><apex:inputSecret id="password" value="{!password}" /><br/></p>
              
  </apex:pageBlockSection>
  <apex:pageBlockButtons location="bottom"><apex:commandButton action="{!login}" value="login" id="login"/></apex:pageBlockButtons>
  </apex:pageBlock></apex:panelGrid>
  </apex:form>
  </center>
</apex:page>


Apex Class:
public  class TestPage {

   public String password { get; set; }
    public String username { get; set; }
    
      public PageReference login() 
      {
      
      if (username == null)

      {
        PageReference newPage = new PageReference('/apex/ThankYou');
        newPage.setRedirect(true);
        
        return newPage;
       }
    
    
    else
    {

    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter value'));

    return null;
    }


   
   }
}


I want to write a test class for that login Page. I dont know how to write test class.Please help me to reach out to that target.


Regards,
M.D.Luvis.