Code samples I’ll publish in this post are not fakes: they come from real code, released into production.
And they are not only brilliant samples of never tested code: they are samples of never executed code!!! Indeed there are in these code snippets execution path which ever - ever! - fail. Read to believe…
Sample #1 - NullPointerException
at each catch execution
1 | MyClass result = null; |
Sample #2: ArrayIndexOutOfBoundException
at each catch execution
1 | try { |
Sample #3: ClassCastException
whenever if
‘s condition is verified
1 | public class AClass { |