function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kentylerkentyler 

assert equals not working

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

 

Alex.AcostaAlex.Acosta

do you have the annotation @isTest(seeAllData=true)? You may not be seeing all the data. It's a bit hard to help without knowing any of the code.