title: How to use stub() method with Mockito?
body: <p>I'm learning about Mockito and I try to use stub() method. I have a simple code but it's not working because I get this error: "The method stub(int) is undefined for the type SpyTest". I want to know what dependency should I add in the pom file to use this stub() method? Thank you in advance!</p>
  
  <p>This is the code:</p>
  
  <pre><code>package com.dgs.mockito;
  
  import static org.junit.jupiter.api.Assertions.*;
  import static org.mockito.Mockito.mock;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import org.junit.jupiter.api.Test;
  
  class SpyTest {
      @Test
      void test() {
          List arrayListMock = mock(ArrayList.class);
          assertEquals(0, arrayListMock.size());
          stub(arrayListMock.size()).toReturn(5);
      }
  }
  </code></pre>
  
  <p>And this is the pom file:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.dgs.mockito&lt;/groupId&gt;
    &lt;artifactId&gt;mockito-example&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
      &lt;properties&gt;
          &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
          &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;      
          &lt;dependency&gt;
              &lt;groupId&gt;org.hamcrest&lt;/groupId&gt;
              &lt;artifactId&gt;hamcrest-library&lt;/artifactId&gt;
              &lt;version&gt;1.3&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
           &lt;dependency&gt;
              &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
              &lt;artifactId&gt;junit-jupiter-api&lt;/artifactId&gt;
              &lt;version&gt;5.3.1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
           &lt;/dependency&gt;
  
           &lt;dependency&gt;
             &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
             &lt;artifactId&gt;junit-jupiter-engine&lt;/artifactId&gt;
             &lt;version&gt;5.3.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
             &lt;groupId&gt;org.mockito&lt;/groupId&gt;
             &lt;artifactId&gt;mockito-core&lt;/artifactId&gt;
             &lt;version&gt;2.21.0&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
             &lt;groupId&gt;org.mockito&lt;/groupId&gt;
             &lt;artifactId&gt;mockito-junit-jupiter&lt;/artifactId&gt;
             &lt;version&gt;2.21.0&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.junit.platform&lt;/groupId&gt;
              &lt;artifactId&gt;junit-platform-launcher&lt;/artifactId&gt;
              &lt;version&gt;1.2.0&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>I'm watching a tutorial from Udemy and and he are using this stub method. And if I try to manually add the import I get this error: "The import org.mockito.Mockito.stub cannot be resolved". I think I need to add another dependency in the pom file. </p>