Where can I read the debug output of test classes
When you run your test class the debug log does show the logs of even your test execution.
You have to find the user that started the test in question. The user can be found by going to Setup > Develop > Apex Test Execution
and inspecting the Test run to find the email of the user.
The line will look like this:
Test run: yyyy-mm-dd hh:MM:ss, [email protected] (n class[es])
Then at Setup > Monitoring > Debug Logs
add the user who has the [email protected]
email to Monitored Users
.
Log
27.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISmmUALFORCE,INFO;WORKFLOW,INFO
07:54:37.375 (2375302000)|EXECUTION_STARTED
07:54:37.375 (2375362000)|CODE_UNIT_STARTED| [EXTERNAL]|01p90000002IZE6|TestClassName.testMethodName
07:54:37.376 (2376542000)|METHOD_ENTRY| [2]|01p90000002IZE6|TestClassName.TestClassName()
07:54:37.376 (2376557000)|METHOD_EXIT|[2]|TestClassName
07:54:37.376 (2376695000)|SYSTEM_METHOD_ENTRY|[4]|System.debug(ANY)
07:54:37.376 (2376721000)|USER_DEBUG|[4]|DEBUG|My debug statement
07:54:37.376 (2376731000)|SYSTEM_METHOD_EXIT|[4]|System.debug(ANY)
07:54:37.376 (2376752000)|SYSTEM_METHOD_ENTRY|[5]|System.assertEquals(ANY, ANY)
07:54:37.376 (2376776000)|SYSTEM_METHOD_EXIT|[5]|System.assertEquals(ANY, ANY)
07:54:35.608 (2376798000)|CUMULATIVE_LIMIT_USAGE
07:54:35.608|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Number of code statements: 2 out of 200000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10
07:54:35.608|CUMULATIVE_LIMIT_USAGE_END
07:54:37.376 (2376826000)|CODE_UNIT_FINISHED|TestClassName.testMethodName
07:54:37.376 (2376835000)|EXECUTION_FINISHED
Launch your Devloper Console (Username>Developer Console)
Go to Setup>Developer>Apex Test Execution>Select Tests> pick the testing class you want to see the debug logs from can click run.
Go to your Dev Console. In the logs section you will see the ApexTestHandler operation. Double click that log. Then check 'Debug Only'. You will see your System.debug lines.