| Author |
Mockito problem testing for a boolean value
|
Tony Evans
Ranch Hand
Joined: Jun 29, 2002
Posts: 521
|
|
I have a object a controller in which I set cachecontrol headers
In my test for testing this controller I pass in a mockResponse object.
I am trying to find ways to test that the headers have been set. In real life this would be
But in a mock response object this call would always default to false.
I thought this might work, but I dont think its correct for handling an checking boolean returns.
Thanks for any help Tony
|
 |
Tony Evans
Ranch Hand
Joined: Jun 29, 2002
Posts: 521
|
|
I think how mockito works in this case, is it checks was the method called with these parameters in this case
which works.
Now I come to my second problem.
will return
Argument(s) are different! Wanted:
mockResponse.setHeader(
"Last-Modified",
"Wed Sep 21 16:09:42 BST 2011"
);
Which is true as the string date representaion is different to the data the file was last modified.
I tried
This returns
org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
Invalid use of argument matchers!
2 matchers expected, 1 recorded.
This exception may occur if matchers are combined with raw values:
//incorrect:
someMethod(anyObject(), "raw String");
When using matchers, all arguments have to be provided by matchers.
For example:
//correct:
someMethod(anyObject(), eq("String by matcher"));
Thanks for any help Tony
|
 |
 |
|
|
subject: Mockito problem testing for a boolean value
|
|
|