This post has been migrated to http://www.thinkcode.se/blog/2013/07/31/is-the-parameter-used
I watched a presentation by Zsolt Fabok a while ago and saw a technique I hadn’t thought of before. How do you verify that a parameter is used in a simple way? Feed the method with something that usually doesn’t work and verify that something happens.
null and assert that you actually receive a
NullPointerException like this:
There are other ways to trace a parameter or verify that it is being used, but this is a trivial way that often works. Similar to printf debugging. It is not pretty, but it is always available and works.