当前位置: 首页 > 知识库问答 >
问题:

JBehave似乎不执行测试

公孙宗清
2023-03-14

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

你知道有什么问题吗?

共有1个答案

孔安福
2023-03-14

我不确定这是否只是stackoverflow中的简单格式问题,但我可以看到,您在story文件中用四个空白空间缩进了步骤。我认为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'
 类似资料:
  • 在我们的40个节点集群(33个spark Executors/5个节点cassandra)上,使用spark-streaming我们每分钟在cassandra表中插入大约20,000个(除其他外)(with)。我们得到的结果是: 如果我理解正确的话,执行器、和75%的时间是空闲的,并阻止阶段完成······这样的资源浪费!和性能损失。 以下是SparkContext的conf选项:

  • 我试图在我的项目中实现BDD,我也使用Jbehave,我参考了可用的在线材料,我创建了故事文件、Steps类和Runner类,如下所示,但我得到了一些奇怪的异常,我无法解决它。 1)故事文件,'sample.Story' 但是如果我使用Junit运行Runner类,我会得到 如果有人能帮我解决这个问题,那就太好了。

  • 我的代码看起来像 我的文件如下所示 当我运行程序时,我看到 我怎样才能修好它呢?

  • 问题内容: 在最新的Java和Eclipse稳定发行版(Kempler)中,假设存在程序包和类名称,请输入以下代码并执行该代码: 这将打印值4。最初,我认为应该打印2,因为我认为即使没有break语句,每段代码仍保留在case语句中。现在,我认为问题在于如何编译。例如,我目前的信念是在内部使用布尔值来跟踪case语句是否等于该值。如果是,则布尔值为true,并且 所有case语句将被视为true,

  • 在过去的几天里,我从Eclipse切换到了Android Studio,几乎所有的东西都正常工作了。然而,当我生成一个签名的APK时,似乎ProGuard从未运行过。 我正在使用生成签名的APK向导,选择“运行ProGuard”并指定我的ProGuard。cfg作为配置文件。构建过程运行时没有错误,并生成了一个功能性apk,但该apk比Eclipse生成的apk大65%。当我通过Android S

  • /应用程序 index.html --sass ----style.scss --/css ----style.css Gulp CLI版本2.0.1和本地版本4.0.0 运行可以正确运行sass函数并编译我的sass文件。运行启动手表。。。 如果我在style.scss中更改一些样式并保存文件,我会得到: 但没有任何更改传播到css/style.css. 任何帮助都将不胜感激。