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?
When you catch them, count them.
Once you have counted them print them. Print numbers in a unit test isn’t very useful as they are usually ignored. It has to be automated.
You are the one catching the exceptions so you have to check your code to record this. If it not your code, you don’t need to worry about testing it.
Perform a task repeatedly for a second and then print how many times it did it in a second. For long running tests it s can be better to run it for a few seconds and average it. Again, just printing this number is not always very useful.
Are we talking about in a unit test or some other means?
For a unit test, you can use byte code manipulation but this 100x times more complicated than changing the code.
You can use code coverage tools which give you this information and a report. e.g. Emma report or Idea’s built in one. Note: this is not built in to the free version.
You can do this with beanshell for the expression and the debug interface. Again this 1000x more complicated than adding a line to the code.
Normally you would use a debugger for this.
You can’t stop on a condition without changing the code.
Most debuggers support this but they do so by performing a check after stopping the code and automatically continuing if the condition is not met.
Use a Watch instead of Evaluate expression.