• kentyler
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 1
    Replies

if i execute this code

ClientMenuController cmc = new ClientMenuController();
cmc.client_list = Factory.CreateClientList(10);
cmc.name_search_string = '8';
PageReference r = cmc.search_name();
integer actual = cmc.records_found;
integer expected = 1;
system.debug('==============>expected:' + expected);    
system.debug('==============>actual' + actual);

 

i get these debug messages

 

DEBUG:==============>expected:1

DEBUG:==============>actual:1

 

if i put the same code in the test method and call

System.assertEquals(expected, actual);

the test fails with

System Assert Exception Expected 1  Actual 0

 

i don't understand why the values in one of the variables is replaced by 0

 

thanks for any help you can give

 

ken tyler

 

if you copied and pasted this line String htmlBody = '"; then it may be because you open htmlBody with a single quote, but close it with a double quote ken tyler

I have this code in a test

     ClientMenuController cmc = new ClientMenuController();
         cmc.client_list = Factory.CreateClientList(10);
        cmc.name_search_string = '8';
        Test.startTest();
            PageReference r = cmc.search_name();
             Integer expected = 1;
             Integer actual = cmc.records_found;
         Test.stopTest();    
    
         System.assertEquals( expected, actual);

the test fails

if i excute the same code outside of a test and system.debug(actual) it comes out to be 1

why is 1 not equal to 1

 

thanks

ken tyler

sorry for the double posting, i posted in the wrong forum to start with

 

i'm working in the IDE and trying to write the simplest possible test

neither my class nor my test have been saved to the server

since it won't do that until i have the test

and the test has an error i can't figure out

 

 

my class

public  class GroupList

{

public string test;

public string gettest(){
    return 'test';
}
public void settest(string new_value){
    this.test = new_value;
}

}

 

my test

@isTest
public with sharing class testGroupList {

static testMethod void test_value_Test() {
    
           GroupList g = new GroupList();
           g.settest('test');
           string tv = g.gettest();   
        System.assertEquals('test',tv);

}
}

 

i get "method does not exist or incorrect signature on the "g.settest" line... can't figure out what i'm doing wrong

 

thanks

 

ken tyler

i'm trying to write the simplest possible test

my class

public  class GroupList

{

public string test;

public string gettest(){
    return 'test';
}
public void settest(string new_value){
    this.test = new_value;
}

}

 

my test

@isTest
public with sharing class testGroupList {

static testMethod void test_value_Test() {
    
           GroupList g = new GroupList();
           g.settest('test');
           string tv = g.gettest();   
        System.assertEquals('test',tv);

}
}

 

i get "method does not exist or incorrect signature on the "g.settest" line... can't figure out what i'm doing wrong

 

thanks

 

ken tyler

Hello,

 

I need help with the following setScale, not sure why it's not working. I need to be able to set certain number fields with trailing 0. In this case I need a trailing 4 decimal places even if it's 0

 

quantity__c is Number(18, 0) (I had it set to 14,4..nothing changed)

 

m.quantity__c = (m.quantity__c).setScale(4);

 

The value would appear as ie. 10.0

 

If m.quantity__c was a string field I believe the setScale(4) works but i dont want to create unnecessary fields..