java.lang.NoSuchMethodError: cucumber.runtime.Runtime

huangapple 未分类评论46阅读模式
英文:

java.lang.NoSuchMethodError: cucumber.runtime.Runtime

问题

POM xml:  


4.0.0
automacao
selenium
0.0.1
teste

<properties>
	<cucumber.version>4.2.6</cucumber.version>
</properties>

<build>
	<plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <encoding>UTF-8</encoding>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.1</version>
        </plugin>
	</plugins>
</build>

<repositories>
	<repository>
		<id>central2</id>
		<name>Central Repository</name>
		<url>http://repo.maven.apache.org/maven2</url>
		<layout>default</layout>
		<snapshots>
			<enabled>false</enabled>
		</snapshots>
	</repository>
</repositories>

<dependencies>
	<dependency>
		<groupId>net.sourceforge.jexcelapi</groupId>
		<artifactId>jxl</artifactId>
		<version>2.6.12</version>
	</dependency>

	<!-- Selenium -->
	<dependency>
		<groupId>org.seleniumhq.selenium</groupId>
		<artifactId>selenium-java</artifactId>
		<version>3.141.59</version>
	</dependency>
	<!-- commons-io -->
	<dependency>
		<groupId>commons-io</groupId>
		<artifactId>commons-io</artifactId>
		<version>2.4</version>
	</dependency>

	<!-- mysql-connector-java -->
	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<version>8.0.11</version>
	</dependency>

	<dependency>
		<groupId>junit</groupId>
		<artifactId>junit</artifactId>
		<version>4.12</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.seleniumhq.selenium</groupId>
		<artifactId>selenium-chrome-driver</artifactId>
		<version>3.141.59</version>
	</dependency>

	<!-- cucumber-java -->
	<dependency>
		<groupId>io.cucumber</groupId>
		<artifactId>cucumber-java</artifactId>
		<version>${cucumber.version}</version>
	</dependency>

	<!-- cucumber-junit -->
	<dependency>
		<groupId>io.cucumber</groupId>
		<artifactId>cucumber-junit</artifactId>
		<version>${cucumber.version}</version>
	</dependency>

	<dependency>
		<groupId>info.cukes</groupId>
		<artifactId>gherkin</artifactId>
		<version>2.12.2</version>
		<scope>provided</scope>
	</dependency>
</dependencies>
```

Runner class:

package runners;

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

@RunWith(Cucumber.class)
@CucumberOptions(
		features = "src/main/resources/features/Contas.feature",
		glue = "steps",
		tags = "@test1")

public class Runner {

}
英文:

I'm on a Java-Junit-Cucumber-Selenium project. When running the tests through Junit everything goes well, but I can't run via cucumber.
I tried with several versions.

POM xml:

&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
	xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
	xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
	&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
	&lt;groupId&gt;automacao&lt;/groupId&gt;
	&lt;artifactId&gt;selenium&lt;/artifactId&gt;
	&lt;version&gt;0.0.1&lt;/version&gt;
	&lt;description&gt;teste&lt;/description&gt;
	
	&lt;properties&gt;
		&lt;cucumber.version&gt;4.2.6&lt;/cucumber.version&gt;
	
	
	&lt;/properties&gt;
	

	&lt;build&gt;
		&lt;plugins&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                &lt;version&gt;3.8.1&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;encoding&gt;UTF-8&lt;/encoding&gt;
                    &lt;source&gt;1.8&lt;/source&gt;
                    &lt;target&gt;1.8&lt;/target&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                &lt;version&gt;2.22.1&lt;/version&gt;
            &lt;/plugin&gt;
		&lt;/plugins&gt;
	&lt;/build&gt;

	&lt;repositories&gt;
		&lt;repository&gt;
			&lt;id&gt;central2&lt;/id&gt;
			&lt;name&gt;Central Repository&lt;/name&gt;
			&lt;url&gt;http://repo.maven.apache.org/maven2&lt;/url&gt;
			&lt;layout&gt;default&lt;/layout&gt;
			&lt;snapshots&gt;
				&lt;enabled&gt;false&lt;/enabled&gt;
			&lt;/snapshots&gt;
		&lt;/repository&gt;

	&lt;/repositories&gt;

	&lt;dependencies&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;net.sourceforge.jexcelapi&lt;/groupId&gt;
			&lt;artifactId&gt;jxl&lt;/artifactId&gt;
			&lt;version&gt;2.6.12&lt;/version&gt;
		&lt;/dependency&gt;


		&lt;!-- Selenium --&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
			&lt;artifactId&gt;selenium-java&lt;/artifactId&gt;
			&lt;version&gt;3.141.59&lt;/version&gt;
		&lt;/dependency&gt;
		&lt;!-- https://mvnrepository.com/artifact/commons-io/commons-io --&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;commons-io&lt;/groupId&gt;
			&lt;artifactId&gt;commons-io&lt;/artifactId&gt;
			&lt;version&gt;2.4&lt;/version&gt;
		&lt;/dependency&gt;



		&lt;!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;mysql&lt;/groupId&gt;
			&lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
			&lt;version&gt;8.0.11&lt;/version&gt;
		&lt;/dependency&gt;


		&lt;dependency&gt;
			&lt;groupId&gt;junit&lt;/groupId&gt;
			&lt;artifactId&gt;junit&lt;/artifactId&gt;
			&lt;version&gt;4.12&lt;/version&gt;
			&lt;scope&gt;test&lt;/scope&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
			&lt;artifactId&gt;selenium-chrome-driver&lt;/artifactId&gt;
			&lt;version&gt;3.141.59&lt;/version&gt;
		&lt;/dependency&gt;

		&lt;!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java --&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;io.cucumber&lt;/groupId&gt;
			&lt;artifactId&gt;cucumber-java&lt;/artifactId&gt;
			&lt;version&gt;${cucumber.version}&lt;/version&gt;
		&lt;/dependency&gt;

		&lt;!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit --&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;io.cucumber&lt;/groupId&gt;
			&lt;artifactId&gt;cucumber-junit&lt;/artifactId&gt;
			&lt;version&gt;${cucumber.version}&lt;/version&gt;
		&lt;/dependency&gt;

		&lt;dependency&gt;
			&lt;groupId&gt;info.cukes&lt;/groupId&gt;
			&lt;artifactId&gt;gherkin&lt;/artifactId&gt;
			&lt;version&gt;2.12.2&lt;/version&gt;
			&lt;scope&gt;provided&lt;/scope&gt;
		&lt;/dependency&gt;



	&lt;/dependencies&gt;

&lt;/project&gt;

I encountered similar problems, but no solution solved my problem.
I have used the same code in other projects successfully.
Runner class:

package runners;

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

@RunWith(Cucumber.class)
@CucumberOptions(
		features = &quot;src/main/resources/features/Contas.feature&quot;,
		glue = &quot;steps&quot;,
		tags =&quot;@test1&quot;)

public class Runner {

}

答案1

得分: 0

使用要么info.cukes的依赖,要么io.cucumber。不要混用它们。因此,请将gherkin依赖项的群组ID更改为"io.cucumber",因为您使用的其他cucumber依赖项的群组ID都是"io.cucumber",或者您也可以对所有cucumber依赖项使用info.cukes。
这是Maven仓库链接:https://mvnrepository.com/artifact/io.cucumber/gherkin。请参考此链接,并使用其中的任何稳定版本修改gherkin依赖项。
我找到的一个稳定版本如下:

<!-- https://mvnrepository.com/artifact/io.cucumber/gherkin -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>gherkin</artifactId>
    <version>5.1.0</version>
</dependency>

希望您的问题能够得到解决。谢谢。

英文:

Use Either the dependencies with info.cukes or io.cucumber.Don't use it together. So Could you change the gherkin dependency with group id as "io.cucumber" as the rest of the cucumber dependencies you used are with group id "io.cucumber" or you could also use info.cukes for all of the cucumber dependencies
This is the mvn repository link <https://mvnrepository.com/artifact/io.cucumber/gherkin>.Do refer this and modify the gherkin dependency with any of these stable version.
One of the stable version I found is the below one

&lt;dependency&gt;
    &lt;groupId&gt;io.cucumber&lt;/groupId&gt;
    &lt;artifactId&gt;gherkin&lt;/artifactId&gt;
    &lt;version&gt;5.1.0&lt;/version&gt;
&lt;/dependency&gt;

Hope your issue will get solved.Thanks

huangapple
  • 本文由 发表于 2020年4月8日 08:55:30
  • 转载请务必保留本文链接:https://java.coder-hub.com/61091707.html
匿名

发表评论

匿名网友

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

确定