Print Stacktrace of 'sibling' calls for Test First
Hi,
I want to know exactly what certain actions do in order to emulate some of it programmatically while testing.
Specifically, I want to know what happens when I push a swing button, type characters etc. without guessing and println-*** inside overrides.
Is there a way to tell the program to print every method call (stacktrace fashion) for certain actions? I think Ruby has something like that. Maybe Java has the same trick.
Something like recording maybe?
[491 byte] By [
gewittera] at [2007-11-26 14:21:22]

# 5
> Is there a way to tell the program to print every
> method call (stacktrace fashion) for certain actions?
> I think Ruby has something like that. Maybe Java has
> the same trick.
One thing I've done in the past to try to understand inscrutable code is to go to the method that is called last and drop this in:
try {
throw new RuntimeException();
} catch (Exception e) {
e.printStackTrace();
}
Then you can see all the method calls leading to that point. I think you can even get the stack this way without throwing an exception in newer versions of Java (not sure which version added this.)
Realize, however, that Swing is multi-threaded and you might have a hard time linking results to the initial events in some cases.