簡體   English   中英

Getting java.lang.ExceptionInInitializerError at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters trying to run Tests class

[英]Getting java.lang.ExceptionInInitializerError at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters trying to run Tests class

這是dropbox_link ,如果有人想調查。 發現自己處於試圖運行測試場景的泡菜中,intelliJ 在第一步拋出 java.lang.ExceptionInInitializerError,StepDefinition class 如下:

package automation.glue;

import automation.config.AutomationFrameworkConfiguration;
import automation.drivers.DriverSingleton;
import automation.pages.CheckoutPage;
import automation.pages.HomePage;
import automation.pages.SignInPage;
import automation.utils.ConfigurationProperties;
import automation.utils.Constants;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import org.junit.Before;
import org.openqa.selenium.WebDriver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;

import static org.junit.Assert.assertEquals;

@ContextConfiguration(classes = AutomationFrameworkConfiguration.class)
public class StepDefinition {
    private WebDriver driver;
    private HomePage homePage;
    private SignInPage signInPage;
    private CheckoutPage checkoutPage;

    @Autowired
    ConfigurationProperties configurationProperties;

    @Before
    public void initializeObjects(){
        DriverSingleton.getInstance(configurationProperties.getBrowser());
        homePage = new HomePage();
        signInPage = new SignInPage();
        checkoutPage = new CheckoutPage();
    }

    @Given("^I go to the Website")
    public void i_go_to_the_Website(){
        driver = DriverSingleton.getDriver();
        driver.get(Constants.URL);
    }

    @When("^I click on Sign in button")
    public void i_click_on_sign_in_button(){
        homePage.clickSignIn();
    }

    @And("^I specify my credentials and click login")
    public void i_specify_my_credentials_and_click_login(){
        signInPage.logIn(configurationProperties.getEmail(), configurationProperties.getPassword());
    }

    @Then("^I can log into the website")
    public void i_can_log_into_the_website(){
        assertEquals(configurationProperties.getUsername(), homePage.getUserName());
    }
}

似乎@Autowired 不想在步驟定義中注入 ConfigurationProperties 的實例,但我不明白為什么。 這是 ConfigurationProperties 的代碼:

package automation.utils;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

@Component
@PropertySource("framework.properties")
public class ConfigurationProperties {

    @Value("${browser}")
    private String browser;

    @Value("${email}")
    private String email;

    @Value("${password}")
    private String password;

    @Value("${username}")
    private String username;

    public String getBrowser() {
        return browser;
    }

    public void setBrowser(String browser) {
        this.browser = browser;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}

@ComponentScan 在我的 AutomationFrameworkProperties class 中為 @Component 搜索文件夾“自動化”:

package automation.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan("automation")
public class AutomationFrameworkConfiguration {
    public AutomationFrameworkConfiguration(){}
}

為了運行這一切,我正在使用 RunTests:

package automation;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        plugin = {"pretty", "html:target/cucumber-reports"},
        features = "src/main/resources/features"
)
public class RunTests {
    @Test
    public void test(){}
}

畢竟我收到了這個錯誤:

C:\Users\dkreminskyi\.jdks\openjdk-17.0.1\bin\java.exe -ea -DnodeNamesHandler=org.jetbrains.plugins.cucumber.java.run.CucumberTestTreeNodeManager -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3\lib\idea_rt.jar=51512:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3\plugins\junit\lib\junit5-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3\plugins\junit\lib\junit-rt.jar;C:\Users\dkreminskyi\IdeaProjects\automationframework_laurentiu\target\test-classes;C:\Users\dkreminskyi\IdeaProjects\automationframework_laurentiu\target\classes;C:\Users\dkreminskyi\Downloads\jar_files_annotations_5.3\spring-beans-5.3.9.jar;C:\Users\dkreminskyi\Downloads\jar_files_annotations_5.3\spring-core-5.3.9.jar;C:\Users\dkreminskyi\Downloads\jar_files_annotations_5.3\spring-jcl-5.3.9.jar;C:\Users\dkreminskyi\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\dkreminskyi\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\dkreminskyi\.m2\repository\io\cucumber\cucumber-java\2.1.0\cucumber-java-2.1.0.jar;C:\Users\dkreminskyi\.m2\repository\io\cucumber\cucumber-core\2.1.0\cucumber-core-2.1.0.jar;C:\Users\dkreminskyi\.m2\repository\info\cukes\cucumber-html\0.2.6\cucumber-html-0.2.6.jar;C:\Users\dkreminskyi\.m2\repository\io\cucumber\cucumber-jvm-deps\1.0.6\cucumber-jvm-deps-1.0.6.jar;C:\Users\dkreminskyi\.m2\repository\io\cucumber\gherkin\5.0.0\gherkin-5.0.0.jar;C:\Users\dkreminskyi\.m2\repository\io\cucumber\tag-expressions\1.0.1\tag-expressions-1.0.1.jar;C:\Users\dkreminskyi\.m2\repository\io\cucumber\cucumber-junit\2.1.0\cucumber-junit-2.1.0.jar;C:\Users\dkreminskyi\.m2\repository\info\cukes\cucumber-java\1.2.5\cucumber-java-1.2.5.jar;C:\Users\dkreminskyi\.m2\repository\info\cukes\cucumber-core\1.2.5\cucumber-core-1.2.5.jar;C:\Users\dkreminskyi\.m2\repository\info\cukes\cucumber-jvm-deps\1.0.5\cucumber-jvm-deps-1.0.5.jar;C:\Users\dkreminskyi\.m2\repository\info\cukes\gherkin\2.12.2\gherkin-2.12.2.jar;C:\Users\dkreminskyi\.m2\repository\org\springframework\spring-test\4.3.12.RELEASE\spring-test-4.3.12.RELEASE.jar;C:\Users\dkreminskyi\.m2\repository\org\springframework\spring-core\4.3.12.RELEASE\spring-core-4.3.12.RELEASE.jar;C:\Users\dkreminskyi\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\dkreminskyi\.m2\repository\org\springframework\spring-context\4.3.12.RELEASE\spring-context-4.3.12.RELEASE.jar;C:\Users\dkreminskyi\.m2\repository\org\springframework\spring-beans\4.3.12.RELEASE\spring-beans-4.3.12.RELEASE.jar;C:\Users\dkreminskyi\.m2\repository\org\springframework\spring-expression\4.3.12.RELEASE\spring-expression-4.3.12.RELEASE.jar;C:\Users\dkreminskyi\.m2\repository\org\springframework\spring-aop\4.3.12.RELEASE\spring-aop-4.3.12.RELEASE.jar;C:\Users\dkreminskyi\.m2\repository\org\seleniumhq\selenium\selenium-java\3.141.59\selenium-java-3.141.59.jar;C:\Users\dkreminskyi\.m2\repository\org\seleniumhq\selenium\selenium-api\3.141.59\selenium-api-3.141.59.jar;C:\Users\dkreminskyi\.m2\repository\org\seleniumhq\selenium\selenium-chrome-driver\3.141.59\selenium-chrome-driver-3.141.59.jar;C:\Users\dkreminskyi\.m2\repository\org\seleniumhq\selenium\selenium-edge-driver\3.141.59\selenium-edge-driver-3.141.59.jar;C:\Users\dkreminskyi\.m2\repository\org\seleniumhq\selenium\selenium-firefox-driver\3.141.59\selenium-firefox-driver-3.141.59.jar;C:\Users\dkreminskyi\.m2\repository\org\seleniumhq\selenium\selenium-ie-driver\3.141.59\selenium-ie-driver-3.141.59.jar;C:\Users\dkreminskyi\.m2\repository\org\seleniumhq\selenium\selenium-opera-driver\3.141.59\selenium-opera-driver-3.141.59.jar;C:\Users\dkreminskyi\.m2\repository\org\seleniumhq\selenium\selenium-remote-driver\3.141.59\selenium-remote-driver-3.141.59.jar;C:\Users\dkreminskyi\.m2\repository\org\seleniumhq\selenium\selenium-safari-driver\3.141.59\selenium-safari-driver-3.141.59.jar;C:\Users\dkreminskyi\.m2\repository\org\seleniumhq\selenium\selenium-support\3.141.59\selenium-support-3.141.59.jar;C:\Users\dkreminskyi\.m2\repository\net\bytebuddy\byte-buddy\1.8.15\byte-buddy-1.8.15.jar;C:\Users\dkreminskyi\.m2\repository\org\apache\commons\commons-exec\1.3\commons-exec-1.3.jar;C:\Users\dkreminskyi\.m2\repository\com\google\guava\guava\25.0-jre\guava-25.0-jre.jar;C:\Users\dkreminskyi\.m2\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;C:\Users\dkreminskyi\.m2\repository\org\checkerframework\checker-compat-qual\2.0.0\checker-compat-qual-2.0.0.jar;C:\Users\dkreminskyi\.m2\repository\com\google\errorprone\error_prone_annotations\2.1.3\error_prone_annotations-2.1.3.jar;C:\Users\dkreminskyi\.m2\repository\com\google\j2objc\j2objc-annotations\1.1\j2objc-annotations-1.1.jar;C:\Users\dkreminskyi\.m2\repository\org\codehaus\mojo\animal-sniffer-annotations\1.14\animal-sniffer-annotations-1.14.jar;C:\Users\dkreminskyi\.m2\repository\com\squareup\okhttp3\okhttp\3.11.0\okhttp-3.11.0.jar;C:\Users\dkreminskyi\.m2\repository\com\squareup\okio\okio\1.14.0\okio-1.14.0.jar;C:\Users\dkreminskyi\.m2\repository\com\github\jesg\phantomjsdriver\2.0.0\phantomjsdriver-2.0.0.jar;C:\Users\dkreminskyi\AppData\Roaming\JetBrains\IdeaIC2021.3\plugins\cucumber-java\lib\cucumber-jvmFormatter.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 automation.RunTests
    Given I go to the Website                    # StepDefinition.i_go_to_the_Website()
      java.lang.ExceptionInInitializerError
    at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java:807)
    at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:574)
    at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:530)
    at cucumber.runtime.xstream.LocalizedXStreams$LocalizedXStream.<init>(LocalizedXStreams.java:76)
    at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:48)
    at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:39)
    at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:40)
    at cucumber.api.TestStep.executeStep(TestStep.java:102)
    at cucumber.api.TestStep.run(TestStep.java:83)
    at cucumber.api.TestCase.run(TestCase.java:58)
    at cucumber.runner.Runner.runPickle(Runner.java:80)
    at cucumber.runtime.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:140)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:68)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:23)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:73)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:99)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:41)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at cucumber.api.junit.Cucumber$1.evaluate(Cucumber.java:108)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
    at ✽.I go to the Website(src/main/resources/features/Signin.feature:3)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module @61e717c2
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
    at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
    at cucumber.deps.com.thoughtworks.xstream.core.util.Fields.locate(Fields.java:39)
    at cucumber.deps.com.thoughtworks.xstream.converters.collections.TreeMapConverter.<clinit>(TreeMapConverter.java:50)
    at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java:807)
    at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:574)
    at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:530)
    at cucumber.runtime.xstream.LocalizedXStreams$LocalizedXStream.<init>(LocalizedXStreams.java:76)
    at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:48)
    at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:39)
    at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:40)
    at cucumber.api.TestStep.executeStep(TestStep.java:102)
    at cucumber.api.TestStep.run(TestStep.java:83)
    at cucumber.api.TestCase.run(TestCase.java:58)
    at cucumber.runner.Runner.runPickle(Runner.java:80)
    at cucumber.runtime.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:140)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:68)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:23)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:73)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:99)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:41)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at cucumber.api.junit.Cucumber$1.evaluate(Cucumber.java:108)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

    When I click on Sign in button               # StepDefinition.i_click_on_sign_in_button()
    And I specify my credentials and click login # StepDefinition.i_specify_my_credentials_and_click_login()
    Then I can log into the website              # StepDefinition.i_can_log_into_the_website()

java.lang.ExceptionInInitializerError
    at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java:807)
    at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:574)
    at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:530)
    at cucumber.runtime.xstream.LocalizedXStreams$LocalizedXStream.<init>(LocalizedXStreams.java:76)
    at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:48)
    at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:39)
    at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:40)
    at cucumber.api.TestStep.executeStep(TestStep.java:102)
    at cucumber.api.TestStep.run(TestStep.java:83)
    at cucumber.api.TestCase.run(TestCase.java:58)
    at cucumber.runner.Runner.runPickle(Runner.java:80)
    at cucumber.runtime.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:140)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:68)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:23)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:73)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:99)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:41)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at cucumber.api.junit.Cucumber$1.evaluate(Cucumber.java:108)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
    at ✽.I go to the Website(src/main/resources/features/Signin.feature:3)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module @61e717c2
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
    at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
    at cucumber.deps.com.thoughtworks.xstream.core.util.Fields.locate(Fields.java:39)
    at cucumber.deps.com.thoughtworks.xstream.converters.collections.TreeMapConverter.<clinit>(TreeMapConverter.java:50)
    at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java:807)
    at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:574)
    at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:530)
    at cucumber.runtime.xstream.LocalizedXStreams$LocalizedXStream.<init>(LocalizedXStreams.java:76)
    at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:48)
    at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:39)
    at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:40)
    at cucumber.api.TestStep.executeStep(TestStep.java:102)
    at cucumber.api.TestStep.run(TestStep.java:83)
    at cucumber.api.TestCase.run(TestCase.java:58)
    at cucumber.runner.Runner.runPickle(Runner.java:80)
    at cucumber.runtime.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:140)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:68)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:23)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:73)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:99)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:41)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at cucumber.api.junit.Cucumber$1.evaluate(Cucumber.java:108)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)


Failed scenarios:
src/main/resources/features/Signin.feature:2 # Testing the authentication

1 Scenarios (1 failed)
4 Steps (1 failed, 3 skipped)
0m0.149s

java.lang.ExceptionInInitializerError
    at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java:807)
    at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:574)
    at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:530)
    at cucumber.runtime.xstream.LocalizedXStreams$LocalizedXStream.<init>(LocalizedXStreams.java:76)
    at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:48)
    at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:39)
    at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:40)
    at cucumber.api.TestStep.executeStep(TestStep.java:102)
    at cucumber.api.TestStep.run(TestStep.java:83)
    at cucumber.api.TestCase.run(TestCase.java:58)
    at cucumber.runner.Runner.runPickle(Runner.java:80)
    at cucumber.runtime.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:140)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:68)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:23)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:73)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:99)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:41)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at cucumber.api.junit.Cucumber$1.evaluate(Cucumber.java:108)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
    at ✽.I go to the Website(src/main/resources/features/Signin.feature:3)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module @61e717c2
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
    at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
    at cucumber.deps.com.thoughtworks.xstream.core.util.Fields.locate(Fields.java:39)
    at cucumber.deps.com.thoughtworks.xstream.converters.collections.TreeMapConverter.<clinit>(TreeMapConverter.java:50)
    at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java:807)
    at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:574)
    at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:530)
    at cucumber.runtime.xstream.LocalizedXStreams$LocalizedXStream.<init>(LocalizedXStreams.java:76)
    

Feature: Shopping Automation

  Scenario: Testing the authentication           # src/main/resources/features/Signin.feature:2

Process finished with exit code -1

請給出任何想法,正在觀看課程和其他學生不時遇到同樣的錯誤,但還沒有人弄清楚這一點。 如果有人能解決這個問題,他們應該在這里。 謝謝。

我正在學習為automationpractice.com網站創建自動化項目的課程。

這個課程有些問題,有些依賴太老了,所以第一步在pom.xml中升級

在 RunTests class 中填寫將添加報告的路徑,在路徑末尾添加文件名,例如 index.html 或 report.html。

@RunWith(Cucumber.class)
@CucumberOptions(
        plugin = {"pretty", "html:target/cucumber-reports/report.html"},
        features = "src/main/resources/features"
)
public class RunTests {
    @Test
    public void test(){}
}

由於某種原因,依賴注入不起作用,因此解決此問題的解決方法是直接使用常量,在 StepDefinition class 中:

//@Autowired
//ConfigurationProperties configurationProperties;

@Before
public void initializeObjects(){
    DriverSingleton.getInstance("Chrome");
    homePage = new HomePage();
    signInPage = new SignInPage();
    checkoutPage = new CheckoutPage();
}

@And("^I specify my credentials and click login")
public void i_specify_my_credentials_and_click_login(){
    signInPage.logIn("encodedEmail", "encodedExample");
}

通過這些更改,項目可以運行並創建報告。 我會繼續尋找解決@Autowired 問題。

這是我的項目的鏈接如果您想在我找到使用依賴注入方法的方法時檢查我的代碼。 https://github.com/svascot/automation-practice

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM