I have this error with cucumber when running the runner"java.lang.NoClassDefFoundError: io/cucumber/messages/Messages$JavaMethod"

huangapple go评论70阅读模式
英文:

I have this error with cucumber when running the runner"java.lang.NoClassDefFoundError: io/cucumber/messages/Messages$JavaMethod"

问题

FAILED: runScenario("Register To website", "Optional[User Registration]")
Runs Cucumber Scenarios
java.lang.NoClassDefFoundError: io/cucumber/messages/Messages$JavaMethod
at io.cucumber.core.runner.CachingGlue.createSourceReference(CachingGlue.java:303)
at io.cucumber.core.runner.CachingGlue.lambda$emitStepDefined$5(CachingGlue.java:293)
at java.util.Optional.ifPresent(Unknown Source)
at io.cucumber.core.runner.CachingGlue.emitStepDefined(CachingGlue.java:293)
at io.cucumber.core.runner.CachingGlue.lambda$prepareGlue$3(CachingGlue.java:252)
at java.util.ArrayList.forEach(Unknown Source)
at io.cucumber.core.runner.CachingGlue.prepareGlue(CachingGlue.java:243)
at io.cucumber.core.runner.Runner.runPickle(Runner.java:68)

I have this error when running cucumber with BDD and java

UPdate:
i use this dependancies for Cucumber what is wrong with it


io.cucumber
cucumber-testng
6.4.0


io.cucumber
cucumber-core
6.4.0


io.cucumber
cucumber-java
6.4.0


io.cucumber
gherkin
15.0.0

英文:
FAILED: runScenario("Register To website", "Optional[User Registration]")
        Runs Cucumber Scenarios
java.lang.NoClassDefFoundError: io/cucumber/messages/Messages$JavaMethod
	at io.cucumber.core.runner.CachingGlue.createSourceReference(CachingGlue.java:303)
	at io.cucumber.core.runner.CachingGlue.lambda$emitStepDefined$5(CachingGlue.java:293)
	at java.util.Optional.ifPresent(Unknown Source)
	at io.cucumber.core.runner.CachingGlue.emitStepDefined(CachingGlue.java:293)
	at io.cucumber.core.runner.CachingGlue.lambda$prepareGlue$3(CachingGlue.java:252)
	at java.util.ArrayList.forEach(Unknown Source)
	at io.cucumber.core.runner.CachingGlue.prepareGlue(CachingGlue.java:243)
	at io.cucumber.core.runner.Runner.runPickle(Runner.java:68)

I have this error when running cucumber with BDD and java
1: https://i.stack.imgur.com/8VgxW.png
[2]: https://i.stack.imgur.com/h8SSv.png
[3]: https://i.stack.imgur.com/R5WqZ.png

UPdate :
i use this dependancies for Cucumber what is wrong with it

	<dependency>
		<groupId>io.cucumber</groupId>
		<artifactId>cucumber-testng</artifactId>
		<version>6.4.0</version>
	</dependency>
	<dependency>
		<groupId>io.cucumber</groupId>
		<artifactId>cucumber-core</artifactId>
		<version>6.4.0</version>
	</dependency>
	<dependency>
		<groupId>io.cucumber</groupId>
		<artifactId>cucumber-java</artifactId>
		<version>6.4.0</version>
	</dependency>
	<dependency>
		<groupId>io.cucumber</groupId>
		<artifactId>gherkin</artifactId>
		<version>15.0.0</version>
	</dependency>

答案1

得分: 0

我降级了依赖项,然后它起作用了,因为我使用了 java 8
我的参考资料是Cucumber docs

<dependency>
    <groupId>com.github.javafaker</groupId>
    <artifactId>javafaker</artifactId>
    <version>1.0.2</version>
</dependency>
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-testng</artifactId>
    <version>6.2.0</version>
</dependency>
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-core</artifactId>
    <version>6.2.0</version>
</dependency>
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>6.2.0</version>
</dependency>
英文:

I downgraded the dependencies then it worked because I use java 8
My reference is Cucumber docs

&lt;dependency&gt;
		&lt;groupId&gt;com.github.javafaker&lt;/groupId&gt;
		&lt;artifactId&gt;javafaker&lt;/artifactId&gt;
		&lt;version&gt;1.0.2&lt;/version&gt;
	&lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;io.cucumber&lt;/groupId&gt;
		&lt;artifactId&gt;cucumber-testng&lt;/artifactId&gt;
		&lt;version&gt;6.2.0&lt;/version&gt;
	&lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;io.cucumber&lt;/groupId&gt;
		&lt;artifactId&gt;cucumber-core&lt;/artifactId&gt;
		&lt;version&gt;6.2.0&lt;/version&gt;
	&lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;io.cucumber&lt;/groupId&gt;
		&lt;artifactId&gt;cucumber-java&lt;/artifactId&gt;
		&lt;version&gt;6.2.0&lt;/version&gt;
	&lt;/dependency&gt;

huangapple
  • 本文由 发表于 2020年8月11日 22:01:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/63359809.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定