title: JUnit5 tests ignored with Maven and with Spring Boot
body: <p>I am currently upgrading a project to use JUnit5.
  I managed to import the necessary dependencies from jupiter and mockito extensions, to make all unit test (both Junit 4 and 5) with mocks run fine in IntelliJ. </p>
  
  <p>At the moment my working solution has:</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.mockito&lt;/groupId&gt;
          &lt;artifactId&gt;mockito-core&lt;/artifactId&gt;
          &lt;version&gt;${mockito-core.version}&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&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;${mockito-core.version}&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
                  &lt;artifactId&gt;junit-jupiter-api&lt;/artifactId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
                  &lt;artifactId&gt;junit-jupiter-engine&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&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;${junit.version}&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;${junit.version}&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
          &lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
          &lt;version&gt;${junit.version}&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p><code>mockito-core.version</code> = 3.0.0
  <code>junit.version</code> = 5.2.0</p>
  
  <p><strong>However</strong> when i run tests via Maven, the JUnit5 tests are being ignored.</p>
  
  <p>I saw on this blog: <a href="https://dev.to/martinbelev/how-to-enable-junit-5-in-new-spring-boot-project-29a8" rel="nofollow noreferrer">https://dev.to/martinbelev/how-to-enable-junit-5-in-new-spring-boot-project-29a8</a>  that <code>spring-boot-starter-test</code> imports JUnit4, and therefore I have to exclude <code>junit</code> from this dependency. <em>However</em> <code>spring-boot-starter-test</code> dependency is being imported from a parent pom, so adding this exclusion: </p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;version&gt;2.0.9.RELEASE&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;junit&lt;/groupId&gt;
                  &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>has no effect, the effective dependency <code>org.springframework.boot</code> is the one defined on the parent pom with an older version.</p>
  
  <p>Does anyone know how I can solve this? Thank you in advance!</p>
  
  <p>Edit:</p>
  
  <p>test class is:</p>
  
  <pre><code>import org.junit.jupiter.api.BeforeEach;
  import org.junit.jupiter.api.Test;
  import org.junit.jupiter.api.extension.ExtendWith;
  import org.mockito.Mock;
  import org.mockito.junit.jupiter.MockitoExtension;
  
  @ExtendWith(MockitoExtension.class)
  public class SomeTest {
  
      private static final String TEST = "test";
  
      @Mock
      RetailerService retailerService;
      private Delivery delivery;
  
      @BeforeEach
      public void setUp() {
          when(retailerService.getMessage(any(String.class))).thenReturn(TEST);
          delivery = new Delivery(retailerService);
      }
  
      @Test
      public void should_have_delivery() {
          assertEquals(getExpectedDeliveriesDTOs(), delivery.toDtos());
      }
  
  }
  </code></pre>