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]
# 1
Use a debugger?
es5f2000a at 2007-7-8 2:13:05 > top of Java-index,Other Topics,Patterns & OO Design...
# 2
Yeah... besides that. :)
gewittera at 2007-7-8 2:13:05 > top of Java-index,Other Topics,Patterns & OO Design...
# 3
If you use Spring you can use AOP filters to do this easily. iIt's just configuration.Or you can look at Glassbox.%
duffymoa at 2007-7-8 2:13:05 > top of Java-index,Other Topics,Patterns & OO Design...
# 4
Or you can use Log4J and put it on "trace".%
duffymoa at 2007-7-8 2:13:05 > top of Java-index,Other Topics,Patterns & OO Design...
# 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.

dubwaia at 2007-7-8 2:13:05 > top of Java-index,Other Topics,Patterns & OO Design...