You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Tibor Digana (Jira)" <ji...@apache.org> on 2019/10/17 17:01:00 UTC

[jira] [Commented] (SUREFIRE-1700) @Disabled is not honored for JUnit5 tests having a single @Test method

    [ https://issues.apache.org/jira/browse/SUREFIRE-1700?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16953924#comment-16953924 ] 

Tibor Digana commented on SUREFIRE-1700:
----------------------------------------

[~tfalabella]
Use the latest snapshot version and repository as it is described in https://issues.apache.org/jira/browse/SUREFIRE-1584?focusedCommentId=16951759&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16951759
and let me know if the development version works for you. We have a unit test with {{@Disable}} .

> @Disabled is not honored for JUnit5 tests having a single @Test method
> ----------------------------------------------------------------------
>
>                 Key: SUREFIRE-1700
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1700
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: Maven Failsafe Plugin, Maven Surefire Plugin
>    Affects Versions: 2.22.2, 3.0.0-M3
>            Reporter: Tony Falabella
>            Priority: Minor
>              Labels: junit5
>
> JUnit5's {{@Disabled}} should ignore/skip running any test method with that annotation.  It seems however that if there is a single {{@Test}} method with {{@Disabled}} that test method will still be run. 
> Similar issue noted on StackOverflow: [https://stackoverflow.com/questions/52602351/junit-5-disabled-is-ignored]
> Sample class:
>  package xxx;
> import org.junit.jupiter.api.Disabled;
>  import org.junit.jupiter.api.Test;
>  import org.junit.jupiter.api.extension.ExtendWith;
>  import org.springframework.boot.test.context.SpringBootTest;
>  import org.springframework.test.context.junit.jupiter.SpringExtension;
> import static org.assertj.core.api.Assertions.assertThat;
> @ExtendWith(SpringExtension.class)
>  @SpringBootTest(classes = XyzBoot.class)
>  public class MyTest {
> @Test
>  @Disabled
>  public void testSomething()
> { assertThat(true).isTrue(); }
> }
>   
> Sample pom.xml (this is a multi-module pom that also has child modules of a parent).  The test above is in a child project.
>  
>  <build>
> <plugins>
>  <plugin>
>  <!-- ======================================== -->
>  <!-- Runs UNIT tests (not INTEGRATION tests). -->
>  <!-- ======================================== -->
>  <groupId>org.apache.maven.plugins</groupId>
>  <artifactId>maven-surefire-plugin</artifactId>
>  <!-- Junit5 need 2.22.0 or newer: https://issues.apache.org/jira/browse/SUREFIRE-1330 -->
>  <version>2.22.0</version>
>  ...
>  </plugin>
> <dependencies>
>  ...
>  <dependency>
>  <groupId>org.junit.jupiter</groupId>
>  <artifactId>junit-jupiter-engine</artifactId>
>  <!-- don't force child-projects to use our libs so set it to compile scope -->
>  <scope>compile</scope>
>  </dependency>
>  <dependency>
>  <groupId>org.mockito</groupId>
>  <artifactId>mockito-junit-jupiter</artifactId>
>  <scope>test</scope>
>  </dependency>
>  <dependency>
>  <!-- this is needed or IntelliJ gives junit.jar or junit-platform-launcher:1.3.2 not found errors -->
>  <groupId>org.junit.platform</groupId>
>  <artifactId>junit-platform-launcher</artifactId>
>  <scope>test</scope>
>  </dependency>
>  <dependency>
>  <!-- this is needed or IntelliJ can't run from Run/Debug configs where you pick "JUnit" as the type -->
>  <groupId>org.junit.vintage</groupId>
>  <artifactId>junit-vintage-engine</artifactId>
>  <scope>test</scope>
>  </dependency>
>  </dependencies>
>   
> Note that I've also tried this both with{{ junit-vintage-engine}} and without it (not sure if it would matter) and the issue still happens.
> This is affecting IntelliJ as well as noted here:
> [https://intellij-support.jetbrains.com/hc/en-us/community/posts/360006399720-IDEA-2019-2-2-Ultimate-Edition-ignores-Disabled-for-JUnit5-tests-having-a-single-Test-method]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)