2016-11-14 45 views
0

我面临一个问题与黄瓜标签和Junit设置相关新旧黄瓜有区别。面对黄瓜标签(给定,当时,然后)和JUnit(Cucumber.class,Cucumber.Options(..))与最新和旧黄瓜问题

  1. 我使用黄瓜1.0.2罐和Cucumber.Options(..)
  2. 我使用黄瓜1.2.2罐和CucumberOptions(..)

在第一种情况下@Given,@When,@Then标签工作正常,但在Junit安装中遇到了Cucumber.class和Cucumber.Options()的问题。

在第二种情况下,CucumberOptions(..)(在最新版本中更新了一个)工作正常,但问题与@Given,@When,@Then。

有人可以提供正确的Cucumber标签和JUnit设置相对于jar版本。

案例1: 的pom.xml

<dependency> 
    <groupId>info.cukes</groupId> 
    <artifactId>cucumber-java</artifactId> 
    <version>1.0.2</version> 
    <scope>test</scope> 
</dependency> 
<dependency> 
    <groupId>info.cukes</groupId> 
    <artifactId>cucumber-junit</artifactId> 
    <version>1.0.2</version> 
    <scope>test</scope> 
</dependency> 
<dependency> 
    <groupId>junit</groupId> 
    <artifactId>junit</artifactId> 
    <version>4.10</version> 
    <scope>test</scope> 
</dependency> 

JUnit运行:

import org.junit.runner.RunWith; 
import cucumber.api.CucumberOptions; 
@RunWith(Cucumber.class) 
@CucumberOptions(plugin={"pretty","html:reports/test-report"},tags= "@Smoketest") 
public class JunitRunner { 

} 

案例2:的pom.xml

​​

Junit的Ruuner

@RunWith(Cucumber.class) 
@CucumberOptions(plugin={"pretty","html:reports/test-report"},tags= "@Smoketest") 
public class JunitRunner { 

} 

与1.2.2面临着黄瓜标签问题,如下图所示:

Click the image

回答

0

你应该使用这些进口 - -

import cucumber.api.java.en.Given; 
import cucumber.api.java.en.Then; 
import cucumber.api.java.en.When; 
+0

我觉得你给的包是1.2.2。我是corect吗?如果是的话,Cucumber标签是好的,但面临与Cucmber.class的JUnit亚军设置问题 – Toothless

+0

你得到什么错误 – Grasshopper

+0

@RunWith(Cucumber.class)。在这个“Cucumber.class”中是这样说的,“类不解析类型”。我只是错过了导入“cucumber.api.junit.Cucumber;”包,这是不建议导入鼠标悬停。 – Toothless