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 2022/03/20 22:01:00 UTC

[jira] [Commented] (SUREFIRE-2040) No tests executed with junit-platform-suite and -Dtest=TestSuite

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

Tibor Digana commented on SUREFIRE-2040:
----------------------------------------

It is not truth that the problem comes from combining JUnit4 and JUnit5.
We have a project which proves that it is not a problem.
https://github.com/Tibor17/junit5-mockito-examples

The only problem is with -Dtest=ComponentTestSuite and this results to 0 tests to run if and only if you use {{junit-platform-suite}}.

> No tests executed with junit-platform-suite and -Dtest=TestSuite
> ----------------------------------------------------------------
>
>                 Key: SUREFIRE-2040
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-2040
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: JUnit 5.x support
>    Affects Versions: 3.0.0-M5
>            Reporter: David M. Karr
>            Assignee: Tibor Digana
>            Priority: Major
>             Fix For: 3.0.0-M6
>
>
> My organization is in the process of moving their SpringBoot Maven builds from JUnit 4 to JUnit 5.  Our "default" build runs all the unit tests.  We also have "component tests" and "integration tests" that are specified in a "TestSuite" class.  The build process specifies the name of the suite class on the command line with "-Dtest=ComponentTestSuite", for instance.  Before the move to JUnit 5, this all worked fine.
> In the move to JUnit 5, I modified ComponentTestSuite to be like this:
>     import org.junit.platform.suite.api.SelectClasses;
>     import org.junit.platform.suite.api.Suite;
>     @Suite
>     @SelectClasses(NoteResourceCT.class)
>     public class ComponentTestSuite {
>     }
> Now, when I run "mvn -Dtest=ComponentTestSuite test", it says the following:
>     [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project ...: No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1] 
> There are no other messages.
> My pom.xml basically looks like this:
>     <?xml version="1.0" encoding="UTF-8"?>
>     <project
>     ...
>         <dependencyManagement>
>             <dependencies>
>                 <dependency>
>                     <groupId>org.junit</groupId>
>                     <artifactId>junit-bom</artifactId>
>                     <version>5.8.2</version>
>                     <type>pom</type>
>                     <scope>import</scope>
>                 </dependency>
>             </dependencies>
>         </dependencyManagement>
>         <dependencies>
>             <dependency>
>                 <groupId>org.springframework.boot</groupId>
>                 <artifactId>spring-boot-starter-test</artifactId>
>                 <scope>test</scope>          
>             </dependency>
>             <dependency>
>                 <groupId>org.mockito</groupId>
>                 <artifactId>mockito-junit-jupiter</artifactId>
>                 <version>4.4.0</version>
>                 <scope>test</scope>
>             </dependency>
>             <dependency>
>                 <groupId>junit</groupId>
>                 <artifactId>junit</artifactId>
>                 <version>4.13.2</version>
>                 <scope>test</scope>
>             </dependency>
>             <dependency>
>                 <groupId>org.junit.platform</groupId>
>                 <artifactId>junit-platform-suite-api</artifactId>
>             </dependency>
>             ...
>         </dependencies>
>         <build>
>             <plugins>
>                 ...
>                 <plugin>
>                     <artifactId>maven-surefire-plugin</artifactId>
>                     <version>3.0.0-M5</version>
>                     <configuration>
>                         <reuseForks>false</reuseForks>
>                         <redirectTestOutputToFile>true</redirectTestOutputToFile>
>                     </configuration>
>                 </plugin>
>                 ...
>             </plugins>
>         </build>
>     </project>



--
This message was sent by Atlassian Jira
(v8.20.1#820001)