【问题标题】:Testing Spring webflux complain about "Unfinished Step Verifier". Ho finish the test properly and fully?测试 Spring webflux 抱怨“未完成的步骤验证器”。何正确、完整地完成测试?
【发布时间】:2021-06-17 20:19:59
【问题描述】:

我正在使用 SpringWebflux 进行一些测试。

我在 IDE 中获得了一个亮点,即“未完成的步骤验证器”

这是我的代码:

    @Test
    public void findAllNextMatches() {
        StepVerifier
                .create(repo.findAll())
                .expectNextMatches(u -> u.getId()
                                         .equals(cust1.getId()))
                .expectComplete();
    }

IntellijIdea 突出显示“expectComplete”,并抱怨说:“Unfinished Step Verifier”。

我怎样才能正确地完成测试,以避免上面的称赞?

非常感谢,提前

【问题讨论】:

    标签: spring-webflux project-reactor spring-test


    【解决方案1】:

    我建议使用verifyComplete() 而不是简单的verify(),因为您可以避免使用.expectComplete(),因为您知道测试必须返回一些东西。

    当测试不能返回任何值但我需要执行 Flux 时,我使用 verify()

    docs也建议

    这是一个方便的方法,除了期望之外还调用了 StepVerifier.verify()。

    【讨论】:

      【解决方案2】:
      猜你喜欢
      • 1970-01-01
      • 2018-04-20
      • 2014-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多