You need to sign in to do that
Don't have an account?
Sushma Priya
Debugging Apex
Hi,
I am new to Apex. Say we have an Apex class as below. Please let me know on how to go with debuging the below code if any problem occurs.
public class SimpleProg
{
integer num=10;
Account[] accs;
accs= new Account[NUM];
for(Integer i=0; i<NUM; i++)
{
accs[i]= new Account(name='test ' + i);
}
insert accs;
}
Also pls let me know how to write a Test class for the above.
Thanks.
You can print the value of the varibale and List elemetns . with .
System.debug(i)
then Check debug Log . . You need to add the User for the Debug Log . .
Monitoring --> Debug Log --> Monitored User ->> New . . add the Name of running User . .
Check the debug Logs .
Hi,
You have to simply write the system.debug(‘@@@@@@@@@@@@@@@’ +variableName) inside the code whenever you want to check any variable value.
public class SimpleProg
{
integer num=10;
Account[] accs;
accs= new Account[NUM];
for(Integer i=0; i<NUM; i++)
{
accs[i]= new Account(name='test ' + i);
}
insert accs;
system.debug(‘@@@@@@@@@@@@@@@@@@@’ +accs.size());
}
Now you can check the debug log inside Monitoring --> Debug Log --> Monitored User ->> New . . add the Name of running User . Now search for @@@@@@ inside the debug log , you will find a value just after this which will show you the value as 10 since you have inserted 10 accounts.
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.