Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A set of questions on testing and debugging.

 
Dmitry Zhuravlev
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Is it possible to track the number of exceptions being thrown by application? Can I write a test that will print me such a number? Uncaught exceptions stops the execution, so its easy, but what about caught exceptions?

2) How do I write a test that will tell me the number of activities completed in a second? For example, average number exceptions thrown by code in a second, average number of entities saved per second, average number of users logged to the site per second etc. For example, I want to put some load on my webapp and find out how many entities it can save per second under such a load, where the limit etc

3) I want to know how many times some line is executed. Can I do it without changing the code?

4) I want to see the value of expression during the execution of the code without changing the code (*)

5) I want to stop the execution of my application not in the breakpoint, but only if some expression or variable is equal to some value (for example, stop app if this variable is null). Without changing the code, of course.

(*) probably I can use Watches for this. Idea debugger has this feature and I can see the value of some expression during the execution. But when the execution reaches that line second time an old value is cleared. How can I look at expression value in a dynamical way?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34410
346
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Is it possible to track the number of exceptions being thrown by application? Can I write a test that will print me such a number? Uncaught exceptions stops the execution, so its easy, but what about caught exceptions?

AOP (aspect oriented programming) would be good for this. Take a look at AspectJ or the like.

2) How do I write a test that will tell me the number of activities completed in a second? For example, average number exceptions thrown by code in a second, average number of entities saved per second, average number of users logged to the site per second etc. For example, I want to put some load on my webapp and find out how many entities it can save per second under such a load, where the limit etc

A performance profiling tool would be better than a JUnit test. It will tell you were the most time in your code is spent so you know where to tune.

3) I want to know how many times some line is executed. Can I do it without changing the code?

Some performance tools will tell you this as well.

4) I want to see the value of expression during the execution of the code without changing the code (*)

I agree with the debugger. If you want a more permanent log, change the code. Or maybe use a debugging tool that tracks this info? I don't recall the name of it, but I remember reading about something that keeps track.

5) I want to stop the execution of my application not in the breakpoint, but only if some expression or variable is equal to some value (for example, stop app if this variable is null). Without changing the code, of course.

Watch expressions do this in your debugger.

It feels like there is a bigger question here. Like how to debug production code. Because that's the only reason I can think of why changing code would not be allowed.
 
Dmitry Zhuravlev
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:It feels like there is a bigger question here. Like how to debug production code. Because that's the only reason I can think of why changing code would not be allowed.


Thank you Jeanne!

You are right.

The thing is that I need to debug the code which is not mine, I get it as a dependency from repository. If I want to change that code I'll have to code it, build it, and somehow give it to my program without installing into the main remote repository. Probably I can change maven POM and specify exact path to the dependency instead of repo group/artifact. Thats why I am looking for something more simple - i.e. using the debugging tools without changing the code.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34410
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it. A debugger and profiler are definitely your best bets then. I'd start from "where is the time being spent" for performance rather than the # exceptions, executions of a line. You don't really care if my component sites around throwing exceptions all day if a sort operation takes 99% of the time in my component.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic