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
3 comments:
I have been using FEST for a long time. Should I switch to cotta-assert instead?
The answer is not an easy yes or no. I'll write another blog post explaining it.
With that said, most probably you should not change, for the same reason I told people not to change JUnit to TestNG or vice versa.
The software that is high quality and produce the best value is what matters the most. If switching between tools that are both high quality makes difference in that goal, I think you should consider yourself very lucky.
More often than not, we as engineers argue hard and excitedly about the kind of tools that we use, when we have tons of crap in our code that only human can solve.
Ok, I have finally got around to write my thoughts. Cheers
Post a Comment