So, the only way for Mock objects so that an exception can be thrown?
I believe that this will be the easiest way, but you can also make a stub (otherwise an object that extends the real object and makes it look like throwing an exception every time). Or you can use AOP, but I think using a library like easymock or jmock would be the easiest way.
It seems a little pointless. Perhaps it's better not to accept 100% code coverage?
Whenever I talk about this topic, I like to shift people's mentality from worrying about a certain percentage of coverage, and instead use percentage as a tool to make you a better developer. In other words, using 100% coverage or 50% coverage does not necessarily mean that your code is well written or even works, but using Code Coverage as a key indicator when you develop code regarding what you are weakening when writing tests, etc .... good idea.
My personal opinion about your question is that if this is the logic that your application makes, then it is worth checking. Therefore, if you catch and exclude and reconfigure a lie from a method, you should pass a test for this. If you catch the exception and end it in another exception, you should check this out. If you catch an exception and do nothing, then it should be the smell of code that needs to be fixed, because it can lead to all kinds of uncontrollable side effects.
As for the fact that 100% did not anger him, I would say that it is not worth it. You must find a good level of comfort for yourself (maybe 80%, maybe 90%) and stick to it. But I would not base it on the types of tests (for example, on testing the exception logic), it should be based only on the general scope and is considered as an indicator that you are not writing your tests when fixing the code.
Daniel Roop
source share