junit - 运行黄瓜代码时出现io.cucumber.junit.UndefinedStepException
问题描述
我已经使用 Cucumber 开发了一个 UI 自动化项目。当我尝试使用 cucumber 和 JUnit runner 运行测试时,我收到:io.cucumber.junit.UndefinedStepException:“用户在 Goibibo 应用程序登录页面”步骤未定义。您可以使用下面的代码片段来实现它:
项目结构如下:
TestRunner.java 代码如下:
POM.xml 依赖项 -
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<testSourceDirectory>src/test/java</testSourceDirectory>
<includes>
<include>**/*TestRunner.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.22.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium.</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>junit.</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>5.2.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
</dependencies>
解决方案
推荐阅读
- python - 在迭代器未完全耗尽时获取 StopIteration 异常
- r - 在 str_replace 中使用 ascii
- parsing - 获取响应时出现 Groovy 错误:groovyx.net.http.HTTPBuilder handleResponse WARNING: Error parsing 'text/html' response groovy.json.JsonException
- javascript - 如何在 TypeScript 中访问接口的底层原始字段?
- python - 迭代到字典中的列表
- ansible - 从 Bitbucket 触发 ansible 作业
- flash - 从 Adobe Animate 中打开的 FLA 文件中导出所有项目
- sql - 在 SQL 中只返回 false 值
- lisp - lisp 更新列表函数
- postgresql - 如何在具有一列作为 json 值的 postgres db 中进行查询