我正在尝试使用Serenity BDD和JBehave框架中的登录功能来执行一个非常简单的故事。但是,我所有的步骤都被标记为PENDING并被跳过。请帮助我了解我的代码到底出了什么问题。
我确保我的故事文件和步骤文件中的步骤彼此完全匹配,并且在空格或制表符方面没有差异。
故事文件
Story: Application Login
Narrative:
As an user, I want to successfully login into the application upon providing valid credential
Scenario: Login with valid credential
Given Launch the application
When Input the credential
Then Login to the application
步骤班
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;
import net.thucydides.core.annotations.Steps;
import tests.LoginTest;
public class LoginSteps {
@Steps
LoginTest usr;
@Given("Launch the application")
public void launchApp() {
usr.beforeSuite();
usr.launchApplication();
}
@When("Input the credential")
public void enterCredential() {
usr.submitLoginForm();
}
@Then("Login to the application")
public void loginApp() {
usr.loginCheck();
usr.afterSuite();
}
}
测试类
package suite;
import net.serenitybdd.jbehave.SerenityStory;
public class Login extends SerenityStory {
}
POM.XML
<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>com.selenium.bdd.serenity</groupId>
<artifactId>seleniumBDDSerenity</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>seleniumBDDSerentity</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.5</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>2.0.33</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-jbehave</artifactId>
<version>1.44.0</version>
</dependency>
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-core</artifactId>
<version>4.3.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<includes>
<include>**/suite/*.java</include>
</includes>
<skipTests>false</skipTests>
<failIfNoTests>false</failIfNoTests>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>2.0.33</version>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
登录
(BeforeStories)
Running story stories/authentication/Login.story
Application Login
(stories/authentication/Login.story)
Using timeout for story Login.story of 300 secs.
Scenario: Login with valid credential
Given Launch the application (PENDING)
When Input the credential (PENDING)
Then Login to the application (PENDING)
@Given("Launch the application")
@Pending
public void givenLaunchTheApplication() {
// PENDING
}
@When("Input the credential")
@Pending
public void whenInputTheCredential() {
// PENDING
}
@Then("Login to the application")
@Pending
public void thenLoginToTheApplication() {
// PENDING
}
(AfterStories)
答案 0 :(得分:0)
我遇到了同样的问题,并已解决。将跑步者类移动到放置LoginSteps的文件夹中。