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
占一 逯占一 逯 

Where to check the output and result by using system.assert & system.debug in Test Class?

As title, I used system.assert & system.debug in test class, I only got case run successful in console. Where to check the debug & asssert output ?
nandan.kollinandan.kolli
put the debugs in main class and run the test class.After running the test class go to the debug logs and check the logs for the main class,

- pavan
Shruti khodaboleShruti khodabole
Hi,
A simple scenario would be to create a test class +methods in which some work is done (e.g. put something into the DB, update a field or whatever). Once this is done you would use System.Assert functions to check what has been done.
 
For example:-
 
integer i = 0;
integer j = 1;
 
//this would throw an error  and cause your test to fail 
System.assertEquals(i,j);
//this would pass
System.assertNotEquals(1,i);
etc...
 
You may put something into the DB via an insert. After running the test class go to the debug logs and check the logs.
 
Thanks,
Shruti Khodabole
Salesforce Developer
http://www.zen4orce.com
 
 
Sukanya BanekarSukanya Banekar
Hi ,
You can check debug logs in developer console or set debug logs through setup 

Hope this helps you to solve your problem.

Thanks,
Sukanya Banekar
atul patil 7atul patil 7
Hi,
You can set the system.debug in your main class and system.assert in test class, Then run the test in developer console
then click on Tests it will show you test results of all methods in your test class and also assert result. you can click on method which are
failed /pass then debug will be open that show you debugs which you set in your main class
User-added image

User-added image

I hope this helps you .
Thanks,
Atul Patil
Salesforce Developer
http://www.zen4orce.com