0

I am writing some BDD tests using Cucumber for my Spring Boot application (v2.2.1), and it works OK.

However, I am facing some performance issue, because the application gets started/stopped for every scenario in the feature file : I am using in-memory DB with Liquibase, so for each scenario, this gets executed (takes a few seconds).

Sure, it's currently guaranteed that my scenarios are very well isolated.. Maybe in some cases I will want this behaviour, but right now, most of my feature files would benefit from a one time set up : since each scenario sets up different records (with no overlap) it needs in the in-memory DB, I could theoretically executed my scenarios in parallel on a single Spring Boot application running.

I saw https://blog.codecentric.de/en/2017/02/integration-testing-strategies-spring-boot-microservices-part-2/ , but it requires to have built the application first, then start it from the jar.

Isn't there a way to do the same, but with the application started once from the Cucumber runner ? any example somewhere ?

Vincent F
  • 6,523
  • 7
  • 37
  • 79
  • Cucumber v5 with `cucumber-spring` will start a single application context and share it between threads like JUnit would. https://github.com/mpkorstanje/cucumber-spring-boot-parallel – M.P. Korstanje Mar 19 '20 at 20:19

1 Answers1

0

Thanks to @mpkorstanje link, I was able to find the issue : while trying to replicate the suggestion in my project, I discovered that one of the config that was scanned had a @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) annotation.. So that was the issue. Now I need to look at a workaround like what is suggested here : @DirtiesContext tears context down after every cucumber test scenario, not class

Vincent F
  • 6,523
  • 7
  • 37
  • 79