Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

While comparing the run of my wizard and a similar standard one, I have to check all entrances into all functions for both cases. Is there some tool that can automate the process? I can't do it by simply inserting the log lines in code, because 98% of the process run inside the code of library functions. Can the java machine catch every entrance or leave in/out of every method and log it somewhere?

share|improve this question
1  
this can be done with aspect oriented programming. I think it is more likely to get an answer for this question if the question is migrated to stackoverflow.com –  k3b May 25 '12 at 9:53
1  
Maybe. But on SO a question without code is considered as a one of worse quality. As for "programmers", there when I asked on testing problems, was readdressed here, too. Aspect works with my code only, not libraries, doesn't it? –  Gangnus May 25 '12 at 10:01
1  
I don't think your assessment of a question without code is considered worse quality is accurate, personally. Worse quality would be questions without context. Code easily provides context, but you've managed to provide plenty of context in your question. Not that this question isn't also appropriate here, but I think it would be just fine there too. –  corsiKa May 25 '12 at 17:27
1  
What is your ultimate goal? Do you need to be informed when your method is called in a real time? Or to count how many times the method is invoked during a certain usage session? Or maybe you need performance measurement / stress testing? Depending on your needs, there may be different approaches. –  bytebuster Jun 9 '12 at 4:11

2 Answers 2

up vote 2 down vote accepted

With Aspect Oriented Programming, you can use an annotation which executes Before (entering), After, or Around (before and after) a method. There isn't anything specifically designed to execute when entering a method, unless you used @After.

For more information regarding the syntax and options, here is a link to Spring's online documentation: http://static.springsource.org/spring/docs/2.0.x/reference/aop.html

share|improve this answer

You can use @Loggable annotation from jcabi-aspects, which wraps all methods you want to debug with a simple logging mechanism:

@Loggable(Loggable.DEBUG)
public String load(URL url) {
  return url.openConnection().getContent();
}

It logs through SLF4J.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.