Java JBehave不';我似乎没有执行这些测试

Java JBehave不';我似乎没有执行这些测试,java,jbehave,Java,Jbehave,这是我第一次使用JBehave,我正试图在项目中创建第一个JBehave,但目前看来测试没有执行这些步骤。 最后,测试说所有的测试用例都顺利通过了,但实际上它们根本没有被执行。我在每个步骤方法中设置断点,我的调试器根本不会阻止我,更不用说这些步骤当前引发的异常了 这是我的设想: Narrative: In order for the user to start using the application, he first needs to register and log in Scenar

这是我第一次使用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");
    }
}
公共类UserRegistrationTest扩展JUnitStores{
公共用户注册测试(){
超级();
this.configuredEmbedder().candidateSteps().add(新用户注册步骤());
}
@凌驾
受保护的列表故事路径(){
返回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'

如果测试找到了你的.story文件,它应该像这样记录:“Running story bdd/users/user\u registration.story”这会出现在你的日志中吗?别担心。测试还可以。我可以运行它,它执行得很好。只有当我尝试执行“测试聚合”而不是仅执行“测试”时,问题才会出现,因为spring引导服务器不会启动(但当我仅执行“梯度测试”时,它会启动)