Why diagnostics?
Let's say your application misbehaves - it doesn't do quite what you expect and it's not obvious why. You go to the source code, add some System.out.println(...) statements, recompile and run a test again. "Aha!" you say, and go back to the source code, add some more debug statements, recompile and run the test once more. You find the bug, correct it and remove the debug statements because you obviously don't want a user to see them. Is this something you recognize? If so, consider using diagnostics.
Diagnostics are basically debug statements describing application behavior or the state of certain data. They should be maintained like the rest of the code, and they should also be configurable at runtime, meaning that all you have to do to turn them on or off is to edit some configuration file (no need to recompile!). Not only is this very convenient, it is also almost essential when using the TextTest approach to testing.
JUseCase diagnostics
If you're having troubles understanding what happens while you're recording or replaying a test using JUseCase, you might want to switch on JUseCase's internal diagnostics which use the log4j package. The easiest way to configure them is to create a normal log4j.properties file (as described on the log4j homepage, see downloads section). Log4j uses a hierarchy structure of loggers, which means that if you enable one logger you also enable all child loggers. The root logger for JUseCase is simply called "jusecase", and here's a list of the rest of the loggers:
- jusecase.setup - JUseCase setup behavior
- jusecase.record - recording behavior
- jusecase.replay - detailed replay behavior
- jusecase.replay.progress - overview of replayed events
- jusecase.components.button - ScriptedButton behavior
- jusecase.components.combo - ScriptedComboBox...
- jusecase.components.filechooser - ScriptedFileChooser...
- jusecase.components.list - ScriptedList...
- jusecase.components.slider - ScriptedSlider...
- jusecase.components.table - ScriptedTable...
- jusecase.components.tabs - ScriptedTabs...
- jusecase.components.textfield - ScriptedTextField...
- jusecase.components.togglebutton - ScriptedToggleButton...
- jusecase.components.tree - ScriptedTree...
- jusecase.components.window - ScriptedWindow...
A template log4j.properties file is provided below. Check the log4j homepage for details on how to set up loggers and appenders.
Enabling the loggers
JUseCase's loggers are enabled by setting the log level to INFO. To enable the e.g. setup log and redirect its output to the console, replace "log4j.logger.jusecase.setup = OFF, void" with "log4j.logger.jusecase.setup = INFO, stdout" in the log4j template provided above.