|
Re: JUnit Reloaded
|
Posted: Dec 29, 2006 10:16 AM
|
|
> That's interesting. What's the interface to > Checker ?
I have different types of Checkers, e.g. a CollectionChecker , a NumberChecker , ObjectChecker etc. ensure() is a static method that is overloaded for each of the different checkers, e.g. ensure(Collection c) , ensure(Number n) , etc. The nice thing is that this way you need just one static import to be able to access all these methods. Another nice feature is that the different checkers can use each other, for example:
ensure(array).size().is(5)
Here ensure(array) returns an CollectionChecker , the call to size() returns a NumberChecker which in turn has the is() method to do the actual verification and throws an Exception in case of an error. This way you can do pretty cool things, e.g. I have written a statistical checker that uses confidence intervals to verify e.g. a heuristic optimizer can return a solution close enough to the optimium in 95% of the cases.
|
|