With the creation of Cotta project, I got a chance to really think hard on simple file operations and tests to see how I can make the API as polite as possible, and I think I have found a good answer.
With the default JUnit 4 assertion, you still don't get the benefit of a static typed language, in that you have to remember the class to use to create the matcher for a certain type.
So I created a JUnit assertion adapter that will allow you to type
ensure.that(yourValue)and get the appropriate assertions object based on the type of the object being passed in. The type of the returned object will have just the assertion methods that are applicable to the value.
This also brings an additional benefit. For example, you can have a list instance and call
ensure.set(list)and it will automatically convert the list to the set and return the set assertion object.
I have just made a release under the cotta project for general feedback
The simple document page is here: http://cotta.sourceforge.net/assertions.html
and the jar can be downloaded here:https://sourceforge.net/project/showfiles.php?group_id=171037