【问题标题】:writing load tests for junit springboot application为junit spring boot应用程序编写负载测试
【发布时间】:2021-05-17 07:14:17
【问题描述】:

我已经编写了以下junit测试。

@SpringBootTest
public class abc {

@Autowired
private ActorService actorService;

@Test
@Transactional
public void testCorrectIdHandlingForNewInsertedActors() {
    int elementsInDb = 0;
    for (Actor a : this.actorService.findAll()) {
        elementsInDb++;
    }

    Actor actor = this.actorService.saveAndSetId(new Actor());

    assertEquals(elementsInDb + 1, actor.getId());
}
}

现在我想为性能测试编写一些负载测试,但我不知道我可以在我的 spring 应用程序中使用哪些工具。我使用 gradle 作为我的构建工具。任何教程将不胜感激。

PS:我已经尝试过 zerocode 但对我不起作用

【问题讨论】:

    标签: spring-boot testing junit


    【解决方案1】:

    您有一些开箱即用的有用功能,例如@RepeatedTest 和@Timeout (请参阅JUnit 5 注释参考here)它们分别允许您重复特定的测试方法@ 987654326@ 次,并设置测试自动失败前的最大时间限制。

    除此之外,要获得更完整和更有意义的负载测试,您应该考虑依赖完整的解决方案,例如 Apache JMeter 或 Gatling,而不是单元测试。

    【讨论】:

      猜你喜欢
      • 2018-07-22
      • 1970-01-01
      • 1970-01-01
      • 2018-07-11
      • 2018-04-01
      • 2021-08-31
      • 2021-07-26
      • 2019-04-24
      • 2012-05-13
      相关资源
      最近更新 更多