« You're Already Using Continuous Flow (poorly) | Main | We're not ready for Kanban »



TrackBack URL for this entry:

Listed below are links to weblogs that reference Inline Assertion Templates for Eclipse:


Feed You can follow this conversation by subscribing to the comment feed for this post.

Daniel Fireman

Nice point of view! I've never thought about assertion as an way to help debug and etc.


Szczepan Faber

Interesting idea. I usually used java 'assert' for the same purpose (for example: assert false).

Using junit is interesting but I think your pattern might be difficult to implement in other IDEs. In IDEA, 'test' dependencies (like jUnit) are not visible for production code (like your User). (unless I'm wrong ;)


If I'm understanding correctly, I'd put the junit jar in my eclipse build-path, but not in the compile phase of my maven config. That way, the "temporary" inline assertion would break the build if it became non-temporary. Am I understanding the usage pattern correctly?

Ben Rady

Ray -- Yep. You can also add it to your maven config as a "test" scope dependency, use the maven eclipse plugin to generate your project, and get the same effect.


Wouldn't it be simpler (especially for large projects) to have Cobertura (http://cobertura.sourceforge.net/) run over it? Or well, to check which methods are called by unit tests in any case - it can't figure out which tests call it with a null password parameter. But still.

Ben Rady

Right, the idea here is that coverage doesnt tell you the whole story. Inline assertions can help you detect cases in your code that are not tested, even if the code is 100% covered.


Seems to me you are just relocating your 'test' i.e. to your production code.

Assuming you aren't practising TDD, I feel this approach requires the same 'brain-storming' (i.e. hindsight, foresight, whatever) to think up the cases.

And so I still think 'assert' is better as it can be switched off (removed) by the compiler.


Ben Rady

Darren, a critical difference between this technique and using the built in Java assertions is that these assertions are meant to be temporary. You add them, run your tests (or have Infinitest run them for you) and remove them as soon as you see the results. Theyre only in your code for a few seconds.

The comments to this entry are closed.