Difference between revisions of "Java Debugging Tips"
From AgileApps Support Wiki
imported>Aeric |
imported>Aeric |
||
Line 1: | Line 1: | ||
===Debug Messages=== | |||
To debug a Java [[class]]: | To debug a Java [[class]]: | ||
:* Add messages to the debug log using | :* Add messages to the debug log using | ||
Line 6: | Line 7: | ||
:* Open the debug log in a separate page: | :* Open the debug log in a separate page: | ||
::* Go to '''[[File:GearIcon.png] > Developer Resources > Debug Log''' | ::* Go to '''[[File:GearIcon.png] > Developer Resources > Debug Log''' | ||
::* | ::* After running the code, refresh the page by clicking '''Debug Log''' in the sidebar. | ||
:* Display a note at the top of the user's page with | :* Display a note at the top of the user's page with | ||
Line 14: | Line 15: | ||
:: <tt>Functions.throwException("message text"); | :: <tt>Functions.throwException("message text"); | ||
:''Learn more:'' | :''Learn more:'' | ||
:* See the [[Class Template]] for code that uses many of those techniques. | |||
===Invoking Methods=== | |||
The [[Unit Test Harness]] is good for automated testing Java methods, but note that database changes don't persist. That's a highly desirable feature in a test harness, but it means you can't run a test and then look for changes interactively, in the GUI. | |||
To view changes interactively, the code can be launched by [[Rule]]. For example, use an [{Event Rule]] that runs when a record is added. (As a precaution, you can set up a condition so that the rule is triggered only when some flag is set.) |
Revision as of 00:34, 10 September 2013
Debug Messages
To debug a Java class:
- Add messages to the debug log using
- Logger.info("message text", "message type");
- (Use the message type for searching, when needed.)
- Open the debug log in a separate page:
- Go to [[File:GearIcon.png] > Developer Resources > Debug Log
- After running the code, refresh the page by clicking Debug Log in the sidebar.
- Display a note at the top of the user's page with
- Functions.showMessage("message text");
- Abort processing and display and error message using:
- Functions.throwException("message text");
- Learn more:
- See the Class Template for code that uses many of those techniques.
Invoking Methods
The Unit Test Harness is good for automated testing Java methods, but note that database changes don't persist. That's a highly desirable feature in a test harness, but it means you can't run a test and then look for changes interactively, in the GUI.
To view changes interactively, the code can be launched by Rule. For example, use an [{Event Rule]] that runs when a record is added. (As a precaution, you can set up a condition so that the rule is triggered only when some flag is set.)