eclipse 1.0.14 版本后的cucumber-java 和cucumber-junit 不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31285776/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
cucumber-java and cucumber-junit after version 1.0.14 does not work
提问by Ripon Al Wasim
I am using Cucumber-JVM and Selenium WebDriver together. I have a Maven project in eclipse and dependency of pom.xml file is as below:
我同时使用 Cucumber-JVM 和 Selenium WebDriver。我在eclipse中有一个Maven项目,pom.xml文件的依赖如下:
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.2</version>
<scope>test</scope>
</dependency>
The content of RunCukesTest.java file is:
RunCukesTest.java 文件的内容是:
import org.junit.runner.RunWith;
import cucumber.junit.Cucumber;
@RunWith(Cucumber.class)
@Cucumber.Options(format = {"pretty", "html:target/cucumber-htmlreport","json-pretty:target/cucumber-report.json"})
public class RunCukesTest {
}
I am getting the error in the following lines of code:
我在以下代码行中收到错误消息:
import cucumber.junit.Cucumber;
@RunWith(Cucumber.class)
@Cucumber.Options(format = {"pretty", "html:target/cucumber-htmlreport","json-pretty:target/cucumber-report.json"})
But when I used the version 1.0.14 it works well. What's the wrong with the latest version?
但是当我使用 1.0.14 版本时它运行良好。最新版本有什么问题?
回答by Vicky
@Cucumber.Options
is deprecateduse @CucumberOptions
instead
@Cucumber.Options
是过时的使用@CucumberOptions
,而不是
@CucumberOptions(
format = "pretty",
features = "//refer to Feature file"
)
Hope this helps you
希望这对你有帮助
回答by troig
The annotation has changed to @CucumberOptions
:
注释已更改为@CucumberOptions
:
And I think json-pretty
has changed to json
in this cucumber version.
我认为在这个黄瓜版本中json-pretty
已更改为json
。
This should work:
这应该有效:
@CucumberOptions(
format = {"pretty", "html:target/cucumber-htmlreport","json:target/cucumber-report.json"}
)
Moreover, according to cucumber-jvm specificationsformat is deprecated. You should replace by plugin
. This also should work:
此外,根据cucumber-jvm 规范格式已被弃用。你应该替换为plugin
. 这也应该有效:
plugin = {"pretty", "html:target/cucumber-htmlreport","json:target/cucumber-report.json"}
Hope it helps
希望能帮助到你
回答by Paizo
with cucumber 1.2.2
黄瓜 1.2.2
<cucumber.version>1.2.2</cucumber.version>
....
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
....
here a sample working test:
这里是一个示例工作测试:
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:features/myfeature.feature", tags = "@Mytag", plugin = {"pretty", "html:target/cucumber"})
public class MYAcceptanceTest {
}
note the import is cucumber.api.junit.Cucumber
instead of cucumber.junit.Cucumber
and you need to add the import for the cucumber options. The stereotype for the option is @CucumberOptions
instead of @Cucumber.Options
请注意导入是cucumber.api.junit.Cucumber
而不是,cucumber.junit.Cucumber
您需要为黄瓜选项添加导入。该选项的刻板印象是@CucumberOptions
而不是@Cucumber.Options
回答by arunkumar sambu
replace @Cucumber.Optionswith @CucumberOptionsand formatwith plugin
用@CucumberOptions替换@Cucumber.Options并用插件格式化
@CucumberOptions(plugin = {"pretty", "html:target/cucumber-htmlreport","json-pretty:target/cucumber-report.json"})
public class RunCukesTest {
}
回答by RRR
Cucumber version is now updated to version 2.0.1. Replace
Cucumber 版本现已更新至 2.0.1 版。代替
<groupId>info.cukes</groupId>
with
和
<groupId>io.cucumber</groupId>
回答by suketup
You can try putting both RunCukesTest.java file and your Feature file in same folder or package.
您可以尝试将 RunCukesTest.java 文件和您的功能文件放在同一文件夹或包中。
回答by Testing Passion
By Adding Below Dependencies above issue got resolved
Please list of dependencies added in the POM
请列出 POM 中添加的依赖项
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>FirstBBDApp</groupId>
<artifactId>FirstBBDApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>FirstBBDApp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.2.5</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-html -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-html</artifactId>
<version>0.2.6</version>
</dependency>
<dependency>
<groupId>net.sourceforge.cobertura</groupId>
<artifactId>cobertura</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/gherkin-jvm-deps -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin-jvm-deps</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>2.0.2-beta</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.7.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit-dep -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.11</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>C:\Program Files\Java\jdk1.8.0_202\lib\tools.jar</systemPath>
</dependency>
</dependencies>
</project>