Thanks for you thoughts on my topic. I like your idea of capturing
the assertions directly in the test code. I will look into the
hamcrest matchers a bit more. Thanks again for commenting so quickly
On Jan 23, 4:26 pm, szczepiq <
szcze...@gmail.com> wrote:
> Hi,
>
> You're right the docs might be better. ArgumentMatcher is a hamcrest
> matcher and it's just a contract of Matchers. You might have a look
> here:
http://code.google.com/p/hamcrest
>
> I realize completely that the point of failure in matchers is worse
> than with plain assertions.
>
> However, there are benefits if you adhere to the contract:
>
> 1. you can use your matcher also when stubbing. If your matcher throws
> exceptions than you wouldn't be able to use it in stubbing.
> 2. you can combine your matcher with other matchers. For example if
> 'validArticle()' returns your matcher you can do the following:
> not(validArticle()), hasItems(validArticle()). not() and hasItems()
> are just some examples of existing hamcrest matchers.
>
> You can also implement an ArgumentMatcher that just captures the arg.
> Then you can get the argument and perform assertions straight in the
> test code.
>
> Cheers,
> Szczepan Faber
>
> On Fri, Jan 23, 2009 at 5:43 PM, Chris Bartling
>
> <
chris.bartl...@gmail.com> wrote:
>
> > The javadoc description for ArgumentMatcher.matches(java.lang.Object
> > argument) makes a statement about never using assertions within this
> > method and favoring returning false instead.
>