Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: java.base doesn#39;t quot;opens java.utilquot; to unnamed module(无法使字段私有最终的java.util.Compator java.util.TreeMap.Compator可访问:java.base不会向未命名的模块打开java.util(q;))
问题描述
我已经创建了一个Cucumber特征文件和STEP文件,然后我点击了&Run Configurations&for Feature文件,我在控制台中看到了以下内容。我如何解决此问题?*Feature: Login into account
Existing user should be able to login to account using correct credentials
Scenario: Login into account with correct credentials # C:/Users/MI/Desktop/CucumberFramework/CucumberFramework/src/test/java/CucumberFramework/featureFiles/Login.feature:4
Given User navigates to stackoverflow website # LoginSteps.user_navigates_to_stackoverflow_website()
java.lang.ExceptionInInitializerError
at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java:820)
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:50)
at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:37)
at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:29)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
at cucumber.runtime.Runtime.runStep(Runtime.java:300)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
at cucumber.runtime.Runtime.run(Runtime.java:122)
at cucumber.api.cli.Main.run(Main.java:36)
at cucumber.api.cli.Main.main(Main.java:18)
at ✽.Given User navigates to stackoverflow website(C:/Users/MI/Desktop/CucumberFramework/CucumberFramework/src/test/java/CucumberFramework/featureFiles/Login.feature:5)
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 @5afa04c
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)
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:820)
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:50)
at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:37)
at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:29)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
at cucumber.runtime.Runtime.runStep(Runtime.java:300)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
at cucumber.runtime.Runtime.run(Runtime.java:122)
at cucumber.api.cli.Main.run(Main.java:36)
at cucumber.api.cli.Main.main(Main.java:18)
And User clicks on the login button on homepage # LoginSteps.user_clicks_on_the_login_button_on_homepage()
And User enters a valid username # LoginSteps.user_enters_a_valid_username()
And User enters a valid password # LoginSteps.user_enters_a_valid_password()
When User clicks on the login button # LoginSteps.user_clicks_on_the_login_button()
Then User should be taken to the successfull login page # LoginSteps.user_should_be_taken_to_the_successfull_login_page()
Failed scenarios:
C:/Users/MI/Desktop/CucumberFramework/CucumberFramework/src/test/java/CucumberFramework/featureFiles/Login.feature:4 # Scenario: Login into account with correct credentials
1 Scenarios (1 failed)
6 Steps (1 failed, 5 skipped)
0m0,357s
java.lang.ExceptionInInitializerError
at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java:820)
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:50)
at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:37)
at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:29)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
at cucumber.runtime.Runtime.runStep(Runtime.java:300)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
at cucumber.runtime.Runtime.run(Runtime.java:122)
at cucumber.api.cli.Main.run(Main.java:36)
at cucumber.api.cli.Main.main(Main.java:18)
at ✽.Given User navigates to stackoverflow website(C:/Users/MI/Desktop/CucumberFramework/CucumberFramework/src/test/java/CucumberFramework/featureFiles/Login.feature:5)
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 @5afa04c
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)
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:820)
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:50)
at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:37)
at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:29)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
at cucumber.runtime.Runtime.runStep(Runtime.java:300)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
at cucumber.runtime.Runtime.run(Runtime.java:122)
at cucumber.api.cli.Main.run(Main.java:36)
at cucumber.api.cli.Main.main(Main.java:18)*
推荐答案
您的黄瓜版本与您的Java版本不兼容。升级黄瓜或降级Java。
由于您正在测试的场景,我猜您遵循的是一个旧教程。此版本是最新的:
https://cucumber.io/docs/guides/10-minute-tutorial/
这篇关于无法使字段私有最终的java.util.Compator java.util.TreeMap.Compator可访问:java.base不会向未命名的模块打开java.util(&q;)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法使字段私有最终的java.util.Compator java.util.TreeMap.Compator可访问:java.base不会向未命名的模块打开java.util(&q;)
- Eclipse 的最佳 XML 编辑器 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- 转换 ldap 日期 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 获取数字的最后一位 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01