io.cucumber.core.exception.CucumberException: не удалось загрузить класс плагина: com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter - PullRequest
1 голос
/ 20 февраля 2020

Я новичок в stackoverflow, у меня действительно проблемы, и мне нужна помощь! :)

Я разрабатываю программу автоматизации тестирования в Java, используя jdk-11 с отчетами Cucumber + Extent.

Когда я пытаюсь запустить свой класс Runner с JUnit, я получаю это сообщение об ошибке:

io.cucumber.core.exception.CucumberException: Couldn't load plugin class: com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter

    at io.cucumber.core.options.PluginOption.loadClass(PluginOption.java:117)
    at io.cucumber.core.options.PluginOption.parsePluginName(PluginOption.java:102)
    at io.cucumber.core.options.PluginOption.parse(PluginOption.java:86)
    at io.cucumber.core.options.RuntimeOptionsBuilder$ParsedPluginData.addPluginName(RuntimeOptionsBuilder.java:238)
    at io.cucumber.core.options.RuntimeOptionsBuilder.addPluginName(RuntimeOptionsBuilder.java:62)
    at io.cucumber.core.options.CucumberOptionsAnnotationParser.addPlugins(CucumberOptionsAnnotationParser.java:97)
    at io.cucumber.core.options.CucumberOptionsAnnotationParser.parse(CucumberOptionsAnnotationParser.java:52)
    at io.cucumber.junit.Cucumber.<init>(Cucumber.java:112)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
    at org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder$DefensiveAnnotatedBuilder.buildRunner(DefensiveAllDefaultPossibilitiesBuilder.java:114)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37)
    at org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder.runnerForClass(DefensiveAllDefaultPossibilitiesBuilder.java:57)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
    at org.junit.vintage.engine.discovery.ClassSelectorResolver.resolveTestClass(ClassSelectorResolver.java:66)
    at org.junit.vintage.engine.discovery.ClassSelectorResolver.resolve(ClassSelectorResolver.java:47)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$resolve$2(EngineDiscoveryRequestResolution.java:134)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1631)
    at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
    at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:185)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:125)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:91)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.run(EngineDiscoveryRequestResolution.java:82)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.resolve(EngineDiscoveryRequestResolver.java:113)
    at org.junit.vintage.engine.discovery.VintageDiscoverer.discover(VintageDiscoverer.java:44)
    at org.junit.vintage.engine.VintageTestEngine.discover(VintageTestEngine.java:63)
    at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:181)
    at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:168)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
Caused by: java.lang.NoClassDefFoundError: cucumber/api/event/ConcurrentEventListener
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at io.cucumber.core.options.PluginOption.loadClass(PluginOption.java:110)
    ... 44 more
Caused by: java.lang.ClassNotFoundException: cucumber.api.event.ConcurrentEventListener
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 54 more

Итак, в моем классе Runner, называемом "LoginPageSuite.class", у меня есть:

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        strict = true,
        features = {"src/test/resources/features/login"},
        glue = {"com/cologni/functional_testing_framework/step_definitions/login"},

        // Reports
        plugin = {"pretty",
                "html:reports/cucumber-html-report",
                "json:reports/cucumber-report.json",
                "com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:reports/extent-report.html"
        }
)
public class LoginPageSuite {

}

И в моем файле "build.gradle" у меня есть эти зависимости:

plugins {
    id 'java'
}

group 'com.cologni'
version '1.0'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

configurations {
    cucumberRuntime {
        extendsFrom testImplementation
    }
}

task cucumber() {
    dependsOn assemble, compileTestJava
    doLast {
        javaexec {
            main = "io.cucumber.core.cli.Main"
            classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
            args = ['--plugin', 'pretty', '--glue', 'com.cologni.functional_testing_framework.step_definitions', 'src/test/resources/features/']
        }
    }
}

dependencies {

    // JUnit API
    testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.6.0'

    // JUnit Engine
    testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.6.0'

    // Cucumber Java
    compile group: 'io.cucumber', name: 'cucumber-java', version: '5.3.0'

    // Cucumber Java 8
    compile group: 'io.cucumber', name: 'cucumber-java8', version: '5.3.0'

    // Cucumber JUnit
    testCompile group: 'io.cucumber', name: 'cucumber-junit', version: '5.3.0'

    //Cucumber Pico Container
    testCompile group: 'io.cucumber', name: 'cucumber-picocontainer', version: '5.3.0'

    // Selenium
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'

    // Cucumber 4 - Extent Reports
    compile group: 'com.aventstack', name: 'extentreports-cucumber4-adapter', version: '1.0.10'

    // JSON
    compile group: 'org.json', name: 'json', version: '20190722'
}

test {
    useJUnitPlatform()
}

Я перепробовал все, я пытался импортировать различные зависимости, такие как:

compile group: 'com.aventstack', name: 'extentreports', version: '4.1.3'

Но я использую адаптер огурца для отчетов по экстентам

compile group: 'com.aventstack', name: 'extentreports-cucumber4-adapter', version: '1.0.10'

Я действительно все перепробовал, все искал, но не могу решить, кто-нибудь может мне помочь? Я буду рад. Большое спасибо!

1 Ответ

0 голосов
/ 20 февраля 2020

Ответ зависит от вас:

    compile group: 'io.cucumber', name: 'cucumber-java', version: '5.3.0'

  // Cucumber 4 - Extent Reports
    compile group: 'com.aventstack', name: 'extentreports-cucumber4-adapter', version: '1.0.10'
...