Closed GoogleCodeExporter closed 8 years ago
Hi,
Current API does not support it explicitly. However, there is a good reason for
that:
usually you should know exactly what happens in your code. After all, you
control how
your system under test is set up. It seems that your case indicates a code
smell.
Don't get fired up - I might be wrong :)
Let's say that you really have a legitimate use case for such feature. You
still can
somehow work around:
1. You can develop a handy method that catches AssertionError and fail only if
there
are 2 AssertionErrors. All mockito verification errors inherit from
AssertionError.
2. You can stub both methods smartly with fancy Answer and later check what's
up...
Original comment by szcze...@gmail.com
on 25 Jan 2010 at 7:08
The reason i wanted this is that i have
private void verifyExistingSessionRequested() {
verify(request, never()).getSession();
verify(request, never()).getSession(true);
verify(request).getSession(false);
}
to verify that getSession(false) was called, and not one of the others. I use
this
multiple times in a test for different methods.
I wanted to create a corresponding method that verifies that either
getSession(true)
or getSession() was called, to be used multiple times for different methods,
some of
which might use getSession() and some of which might use getSession(true).
So in short i wanted to create a reusable verification method. And don't worry,
i
won't get fired up. :)
Original comment by krei...@linuxgods.com
on 25 Jan 2010 at 7:33
How about this? :)
private void verifySessionCreationRequested() {
try {
verify(request, never()).getSession();
verify(request, never()).getSession(true);
throw new WantedButNotInvoked("getSession() or getSession(true)");
} catch (NeverWantedButInvoked ignored) {}
}
Original comment by krei...@linuxgods.com
on 25 Jan 2010 at 7:40
good stuff ;)
Original comment by szcze...@gmail.com
on 25 Jan 2010 at 8:39
Original comment by szcze...@gmail.com
on 14 Feb 2010 at 12:33
Original issue reported on code.google.com by
krei...@linuxgods.com
on 25 Jan 2010 at 6:51