Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is hard to understand your intention from the code posted. You need to demonstrate the creation of a mock object of some collaborating class type and the identity of the class you are testing. Also, the argument of a <code>when()</code> call is supposed to be of the form of a method call on a Mockito mock. In other words,</p> <pre><code>// setting up test fixture MyCollaborator x = Mockito.mock(MyCollaborator.class); when(x.getSetOfObjectToProcess()).thenReturn(newMockedSet); // and then later in test NavigableSet&lt;ObjectToProcess&gt; anotherSetOfObjects = x.getSetOfObjectToProcess(); while(anotherSetOfObjects.iterator() ...) { // or for (ObjectToProcess thisMockedInnerObject : anotherSetOfObjects) { ... </code></pre> <p>So you are missing the <code>x.</code> part of the <code>when()</code> argument.</p> <p>What is less clear is what your intention is in the first place. If you are trying to test the method <code>getSetOfObjectToProcess()</code> on some class, then you shouldn't be mocking that class. You should only be mocking collaborator classes/objects that interact with the class you are testing (often known as the "System Under Test" or SUT).</p> <p>Your code does not even show the creation of a Mockito mock object with the <code>Mockito.mock()</code> method or the <code>@Mock</code> annotation, and at least one of those is necessary to use Mockito. And if <code>getSetOfObjectToProcess()</code> is a static method, then Mockito will not mock it for you regardless.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload