Here’s an elisp function that will just underline your current text. It’s simple, awesome and I use it all the time for my titles. You can put it in the *scratch* and do a C-x C-e and then call it with M-x add-underlining.
(defun add-underlining ()
"Underline titles with an equal sign"
(let* ((initial-line (line-number-at-pos))
(s (make-string end-col ?=)))
(if (= initial-line (line-number-at-pos))
When writing mock tests it is, sometimes, more convenient to assert the values with which the methods were called using the ArgumentCaptor
class instead of the more usual mock verify.
Let’s see both in action.
We’ll take as sample a mock of the List interface.
List<String> myList = mock(List.class);
List<String> myList = new MyList<String> ();
Let’s see how verify-ing would work:
verify (myList).add ("one");
verify (myList).add ("two");
verify (myList).add ("three");
Or since we expect those to be called in that same exact order we could also:
InOrder order = Mockito.inOrder (myList);
order.verify (myList).add ("one");
order.verify (myList).add ("two");
order.verify (myList).add ("three");
Now let’s use ArgumentCaptor instead:
ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass (String.class);
verify (myList).add (argumentCaptor.capture ());
assertEquals (Arrays.asList ("one", "two", "three"), argumentCaptor.getAllValues ());
That seems more streamlined and readable IMO. As you can see the ArgumentCaptor will catch all arguments with which it was called.
If you expect a single value to be captured or if you’re only interested in the last value with which your method was called you can also call:
In our case that call will return “three”.