gpt4 book ai didi

java - JBehave 似乎没有执行测试

转载 作者:搜寻专家 更新时间:2023-11-01 03:36:01 25 4
gpt4 key购买 nike

所以这是我第一次使用 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");
}
}

知道它有什么问题吗?

最佳答案

我不确定这是否只是 stackoverflow 中的简单格式问题,但我可以看到,您在故事文件中用四个空格缩进了步骤。我认为 JBehave 不会以这种方式找到步骤。

因此,您的 .story 文件应如下所示:

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'

关于java - JBehave 似乎没有执行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31412404/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com