t.me/atinfo_chat Telegram группа по автоматизации тестирования

Ошибка при запуске тестов, org.junit.platform.launcher.TestExecutionListener: Provider io.qameta.allure.junitplatform.AllureJunitPlatform could not be instantiated

java
selenium
selenide
maven
Теги: #<Tag:0x00007fb308223b80> #<Tag:0x00007fb3082239f0> #<Tag:0x00007fb308223540> #<Tag:0x00007fb3082231a8>

(Pavel) #1

Создал проект для тестирования. Собрал pom.xml файл для сборки проекта, прописал зависимости, правила сборки и один тест.

вот мой pom.xml файл

<?xml version="1.0" encoding="UTF-8"?>


4.0.0

<groupId>ru.minicom.itphone.web</groupId>
<artifactId>ru.minicom.itphone.web</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <!--selenium versions-->
    <selenium-java.version>3.141.59</selenium-java.version>
    <webdriver-factory.version>4.3</webdriver-factory.version>
    <selenide.version>5.4.1</selenide.version>
    <!--JUnit versions-->
    <junit-jupiter-api.version>5.5.2</junit-jupiter-api.version>
    <junit-jupiter-engine.version>5.5.2</junit-jupiter-engine.version>
    <junit-jupiter-params.version>5.5.2</junit-jupiter-params.version>
    <junit-vintage-engine.version>5.5.2</junit-vintage-engine.version>
    <junit5-engine.version>5.0.0-ALPHA</junit5-engine.version>
    <!--Allure versions-->
    <allure-junit5.version>2.12.1</allure-junit5.version>
    <allure-java-commons.version>2.12.1</allure-java-commons.version>
    <allure-junit-platform.version>2.12.1</allure-junit-platform.version>
    <!--Extra instruments versions-->
    <jsch.version>0.1.55</jsch.version>
    <!--Maven plugin versions-->
    <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
    <junit-platform-surefire-provider.version>1.3.2</junit-platform-surefire-provider.version>
    <aspectj.version>1.9.4</aspectj.version>
    <allure-maven.version>2.10.0</allure-maven.version>
</properties>

<dependencies>
    <!--Dependencies selenium and frameworks for selenium-->
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>${selenium-java.version}</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/ru.stqa.selenium/webdriver-factory -->
    <dependency>
        <groupId>ru.stqa.selenium</groupId>
        <artifactId>webdriver-factory</artifactId>
        <version>${webdriver-factory.version}</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.codeborne/selenide -->
    <dependency>
        <groupId>com.codeborne</groupId>
        <artifactId>selenide</artifactId>
        <version>${selenide.version}</version>
    </dependency>
    <!--Dependencies frameworks for testings-->
    <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>${junit-jupiter-api.version}</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit-jupiter-engine.version}</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-params -->
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-params</artifactId>
        <version>${junit-jupiter-params.version}</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.junit.vintage/junit-vintage-engine -->
    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <version>${junit-vintage-engine.version}</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.junit/junit5-engine -->
    <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit5-engine</artifactId>
        <version>${junit5-engine.version}</version>
    </dependency>
    <!--Dependencies for reporting-->
    <!-- https://mvnrepository.com/artifact/io.qameta.allure/allure-junit5 -->
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-junit5</artifactId>
        <version>${allure-junit5.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-java-commons</artifactId>
        <version>${allure-java-commons.version}</version>
        <scope>compile</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/io.qameta.allure/allure-junit-platform -->
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-junit-platform</artifactId>
        <version>${allure-junit-platform.version}</version>
    </dependency>
    <!--Dependencies extra instruments-->
    <!-- https://mvnrepository.com/artifact/com.jcraft/jsch -->
    <dependency>
        <groupId>com.jcraft</groupId>
        <artifactId>jsch</artifactId>
        <version>${jsch.version}</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <!--Plugin for building maven project-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin.version}</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <!--Plugin for unit testings-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.2</version>
            <configuration>
                <testFailureIgnore>false</testFailureIgnore>
                <argLine>
                    -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                </argLine>
                <systemProperties>
                    <property>
                        <name>junit.jupiter.extensions.autodetection.enabled</name>
                        <value>true</value>
                    </property>
                    <property>
                        <name>allure.results.directory</name>
                        <value>${project.build.directory}/allure-results</value>
                    </property>
                </systemProperties>
            </configuration>
            <dependencies>
                <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjweaver</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
                <!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-surefire-provider -->
                <dependency>
                    <groupId>org.junit.platform</groupId>
                    <artifactId>junit-platform-surefire-provider</artifactId>
                    <version>${junit-platform-surefire-provider.version}</version>
                </dependency>
            </dependencies>
        </plugin>
        <!-- https://mvnrepository.com/artifact/ru.yandex.qatools.allure/allure-maven-plugin -->
        <plugin>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-maven</artifactId>
            <version>${allure-maven.version}</version>
            <configuration>
                <reportVersion>2.6.0</reportVersion>
            </configuration>
        </plugin>
    </plugins>
</build>

Проект собирается и ошибок нет, но когда запускаю тесты, тут начинаются ошибки

SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread “main” java.util.ServiceConfigurationError: org.junit.platform.launcher.TestExecutionListener: Provider io.qameta.allure.junitplatform.AllureJunitPlatform could not be instantiated
at java.util.ServiceLoader.fail(ServiceLoader.java:232)
at java.util.ServiceLoader.access$100(ServiceLoader.java:185)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at java.lang.Iterable.forEach(Iterable.java:74)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:94)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:67)
at com.intellij.junit5.JUnit5IdeaTestRunner.createListeners(JUnit5IdeaTestRunner.java:46)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:45)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonMerge
at com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector.(JacksonAnnotationIntrospector.java:50)
at com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:291)
at io.qameta.allure.model.Allure2ModelJackson.createMapper(Allure2ModelJackson.java:38)
at io.qameta.allure.FileSystemResultsWriter.(FileSystemResultsWriter.java:41)
at io.qameta.allure.AllureLifecycle.getDefaultWriter(AllureLifecycle.java:644)
at io.qameta.allure.AllureLifecycle.(AllureLifecycle.java:70)
at io.qameta.allure.Allure.getLifecycle(Allure.java:70)
at io.qameta.allure.junitplatform.AllureJunitPlatform.(AllureJunitPlatform.java:101)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
… 9 more
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.annotation.JsonMerge
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
… 23 more

Process finished with exit code 1

Никак не пойму, где я ошибся? Спасибо.


(Михаил Братухин) #2

С телефона сложно смотреть, но есть пара вопросов по зависимостям:
Зачем вам винтажная версия? Тем более с surefire плагином выше 22-й версии? Для подключения junit-jupiter есть теперь какой-то единый модуль начиная с 5.5 версии или даже раньше. По итогу многие зависимости есть уже внутри него и не нужно подключать отдельные модули. Ещё есть альфа версия какого-то модуля… и по поводу scope режима. Там все корректно указаны?


(Pavel) #3

Нашёл источник проблемы. В этой зависимости проблема

<dependency>
   <groupId>io.qameta.allure</groupId>
   <artifactId>allure-java-commons</artifactId>
   <version>${allure-java-commons.version}</version>
   <scope>compile</scope>
</dependency>

(Pavel) #4

Убрал данный кусок, полёт нормальный) Спасибо