【发布时间】:2015-07-20 23:55:42
【问题描述】:
所以这是我第一次使用 JBehave,我正在尝试在项目中创建第一个 JBehave,但目前看来测试没有执行这些步骤。 最后测试说所有的测试用例都通过了,没有任何问题,但实际上它们根本没有执行。我在每一步方法中都设置了断点,我的调试器根本没有阻止我,更不用说这些步骤当前抛出的异常了。
这是我的场景:
Narrative:
In order for the user to start using the application, he first needs to register and log in
Scenario: Successful registration
Given a user with email 'test@test.com'
When the user specifies password 'aaaaaa'
Then the user should be successfully registered with email 'test@test.com' and hashed password 'aaaaaa'
步骤:
public class UserRegistrationSteps extends Steps {
@Given("a user with email '$email'")
public void addNewUser(@Named("email") String email) {
User u = new User();
u.setEmail(email);
throw new RuntimeException("test");
}
@When("the user specifies password '$password'")
public void setPassword(@Named("password") String password) {
System.out.println("test");
throw new RuntimeException("test");
}
@Then("the user should be successfully registered with email '$email' and hashed password '$password'")
public void verifySuccessfulRegistration(@Named("email") String email, @Named("password") String password) {
System.out.println("test");
throw new RuntimeException("test");
}
}
和测试执行者:
public class UserRegistrationTest extends JUnitStories {
public UserRegistrationTest() {
super();
this.configuredEmbedder().candidateSteps().add(new UserRegistrationSteps());
}
@Override
protected List<String> storyPaths() {
return Arrays.asList("bdd/users/user_registration.story");
}
}
知道有什么问题吗?
【问题讨论】:
-
如果测试找到您的 .story 文件,它应该记录如下内容:“Running story bdd/users/user_registration.story” 这是否出现在您的日志中?