Closed
Description
It seems that all step expressions are re-compiled into regexes before each scenario.
Steps to reproduce the behavior:
- Given I have feature file like:
Feature: Whatever
Scenario: S1
Given foo
Scenario: S2
Given foo
- and I implement foo step e.g.
@Given("foo")
public void foo() {}
- When I execute the feature file
- Then
io.cucumber.core.stepexpression.StepExpressionFactory.createExpression
method is executed twice with "foo" expression (because there are two scenarios) - therefore "foo" is compiled into regex twice
Expected behavior
"foo" is compiled only once.
Context & Motivation
I noticed that if I remove all bodies of my steps from sources it still takes considerable amount of time to run my tests (e.g., 2.2 seconds for 186 scenarios). Using Java Flight Recorder I collected some profiling data and it seems that a lot of time is being spent in io.cucumber.core.stepexpression.StepExpressionFactory.createExpression
(47% in my case according to flame graph - see below). When I examined that method in debugger I noticed that it's being called more than once with same expressionString
parameter.
Screenshots
Your Environment
- Versions used 6.1.2
- Linux, Gradle, Kotlin