作为更新的一部分,我不得不从info.cukes的cucumber-java(版本为1.2.4)迁移到io.cucumber的cucumber-java(版本为4.2.2),但是在较旧版本的cucumber上成功运行的代码开始抛出错误,提示无法解析导入cumul.api.java.en.Given(或何时/然后)
下面是开始执行的黄瓜类
{
@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:features/functional/",
glue = {"com.jacksparrow.automation.steps_definitions.functional" },
tags = { "@guest_search_in_progress" },
plugin = { "pretty","json:target/cucumber-json/cucumber.json",
"junit:target/cucumber-reports/Cucumber.xml", "html:target/cucumber-
reports"},
strict = false,
dryRun = false,
monochrome = true)
public class FunctionalRunCuke {
}
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin</artifactId>
<version>6.0.14</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
}
请建议我该怎么做
答案 0 :(得分:1)
首先,删除cucumber-jvm-deps
和gherkin
依赖项,因为它们可能会干扰黄瓜4.2.2的传递依赖项。
其次,如果要与JUnit一起使用Cucumber,则还需要导入Junit(v4.12;因为Cucumber尚不支持v5)。然后,您将希望删除cucumber-testng
依赖性(反之亦然,如果要使用TestNg,则删除cucumber-junit
可能会需要一个TestNg依赖性)。
最后,如果导入语句在新的Cucumber版本中的位置已更改,则可能需要更新。
答案 1 :(得分:0)
请在POM中使用以下依赖项,并根据您的框架要求添加JUnit / TestNG依赖项。(只需将4.2.3版更改为V.4.2.2版)
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>datatable</artifactId>
<version>1.1.12</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>4.2.3</version>
<scope>test</scope>
</dependency>
答案 2 :(得分:0)
问题是由于使用了一组错误的黄瓜依存关系。以下是正确的Cucumber依赖集,在迁移到4.0.0时将使用它们,请注意- 1.所有Cucumber依赖项应具有相同的版本。 2.根据您的框架要求使用JUnit或TestNG。