dra*_*ire 2 cucumber gherkin cucumber-jvm
我有一个有两个模块的maven项目.我将在这里提到一个名为app的模块.使用我的RunCukesTest类,我能够执行我的单个场景,它可以看到第一步已经定义并执行它.但IntelliJ的Gherkin插件认为我的第一步是未定义的,而且IntelliJ没有代码帮助,因为我能够在我的步骤def类中定义一个名为LoginStepdefs的步骤.为什么Gherkin插件不能在LoginStepdefs类中找到我的步骤defs?
注意:login.feature旁边有小黄金图标,当鼠标指针悬停在第一步时,它会显示天桥文本"Undefined step reference ..."
根pom.xml是:
<?xml version="1.0" encoding="UTF-8"?>
<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>jpro</groupId>
<artifactId>jpro</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>app</module>
</modules>
</project>
Run Code Online (Sandbox Code Playgroud)
在app模块中,pom.xml是:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>jpro</artifactId>
<groupId>jpro</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>app</artifactId>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
我的目录结构是:
jpro
app
pom.xml
src
main
test
java
pro
j
runner
RunCukesTest.java
stepdef
LoginStepdefs.java
resources
feature
login.feature
pom.xml
Run Code Online (Sandbox Code Playgroud)
login.feature文件包含:
@SC_LOGIN
Feature: Login with username and password
RQ_LOGIN_1: User can login using a username and password
@SC_LOGIN_1 @RQ_LOGIN_1
Scenario: Valid username and valid password
Given I am not logged in
When I go to the home page
Then I should see the login page
When I enter the username jpro
And I enter the password password
And I click the login button
Then I should see that I am logged in as jpro
Run Code Online (Sandbox Code Playgroud)