Невозможно создать Launcher без хотя бы одного TestEngine; рассмотрите возможность добавления JAR реализации движка в classpath в Junit 5

Я получил следующее исключение, когда я попытался запустить контрольный пример в junit5:

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test (default-test) on project CRUD-App: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test failed: There was an error in the forked process
org.junit.platform.commons.util.PreconditionViolationException: Cannot create Launcher without at least one TestEngine; consider adding an engine implementation JAR to the classpath
   at org.junit.platform.commons.util.Preconditions.condition(Preconditions.java:161)
   at org.junit.platform.launcher.core.DefaultLauncher.<init>(DefaultLauncher.java:52)
   at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:42)
   at org.junit.platform.surefire.provider.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:59)
   at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:286)
   at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:240)
   at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)

pom.xml

<dependencies>
    ...
    <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit5-api</artifactId>
        <version>5.0.0-SNAPSHOT</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <plugins>        
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19</version>
            <dependencies>
                <dependency>
                    <groupId>org.junit.platform</groupId>
                    <artifactId>junit-platform-surefire-provider</artifactId>
                    <version>1.0.0-M2</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

Тестовый класс:

public class PersonServiceTest {

    final Database database = Database.from("jdbc:h2:mem:" + App.DB_NAME);

    final PersonService personService = new PersonService(database);

    public PersonServiceTest() {
    }

    @Test
    @DisplayName("@Person#insert()")
    public void testInsert() {
        personService.insert(new PersonBuilder()
                .setId(1).setName("Bhuwan")
                .setAddress("KTM")
                .setContactNo("984849").createPerson()
        );
    }

}

Maven Цель: mvn test

Ответы на вопрос(2)

Ваш ответ на вопрос