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

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

Starz26Starz26

what does the error say? what is the actual value?

 

What are your other methods doing....

asish1989asish1989

Hi

   Try this

         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;

              System.assertEquals( expected, actual);
         Test.stopTest();    
    

DId this post answers your problem..If so please mark it solved .

 

thanks

asish