Skip to content

Unable to change Junit naming strategy #3087

@grappler

Description

@grappler

👓 What did you see?

The test name is "The scenario outline - #1.1: The example scenario outline" even with the following config.

@ConfigurationParameter(
        key = JUNIT_PLATFORM_NAMING_STRATEGY_PROPERTY_NAME,
        value = "short"
)
@ConfigurationParameter(
        key = JUNIT_PLATFORM_SHORT_NAMING_STRATEGY_EXAMPLE_NAME_PROPERTY_NAME,
        value = "pickle"
)

Junit Report

<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="Cucumber" time="0.567" tests="1" skipped="0" failures="0" errors="0" timestamp="2025-10-03T14:19:28.818825900Z">
<testcase classname="An example that has evolved further" name="The &lt;scenario name&gt; scenario outline - #1.1: The example scenario outline" time="0.005">
<system-out><![CDATA[
Given an example scenario outline...........................................passed
When all step definitions are implemented...................................passed
Then the scenario passes....................................................passed
]]></system-out>
</testcase>
</testsuite>

✅ What did you expect to see?

The test name is "The example scenario outline"

<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="Cucumber" time="0.567" tests="1" skipped="0" failures="0" errors="0" timestamp="2025-10-03T14:19:28.818825900Z">
<testcase classname="An example that has evolved further" name="The example scenario outline" time="0.005">
<system-out><![CDATA[
Given an example scenario outline...........................................passed
When all step definitions are implemented...................................passed
Then the scenario passes....................................................passed
]]></system-out>
</testcase>
</testsuite>

📦 Which tool/library version are you using?

cucumber-jvm v7.30
junit 6.0.0

🔬 How could we reproduce it?

Here is an example.

package hellocucumber;

import static io.cucumber.junit.platform.engine.Constants.*;

import org.junit.platform.suite.api.ConfigurationParameter;
import org.junit.platform.suite.api.IncludeEngines;
import org.junit.platform.suite.api.SelectPackages;
import org.junit.platform.suite.api.Suite;

@Suite
@IncludeEngines("cucumber")
@SelectPackages("hellocucumber")
@ConfigurationParameter(
  key = PLUGIN_PROPERTY_NAME,
  value = "pretty," +
    "junit:target/cucumber-reports/cucumber.xml,"
)
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "hellocucumber")
@ConfigurationParameter(
        key = JUNIT_PLATFORM_NAMING_STRATEGY_PROPERTY_NAME,
        value = "short"
)
@ConfigurationParameter(
        key = JUNIT_PLATFORM_SHORT_NAMING_STRATEGY_EXAMPLE_NAME_PROPERTY_NAME,
        value = "pickle"
)
class RunCucumberTest {}
Feature: An example that has evolved further

  Scenario Outline: The <scenario name> scenario outline
    Given an <scenario name> scenario outline
    When all step definitions are implemented
    Then the scenario passes

    Examples:
      | scenario name |
      | example        |
package hellocucumber;

import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;

public class StepDefinitions {

  @Given("^an (.+) scenario outline$")
  public void anExampleScenarioOutline(String scenarioName) {
      if (scenarioName.equals("example")) {
        // Nothing to do: demo
      }
  }

  @When("all step definitions are implemented")
  public void allStepDefinitionsAreImplemented() {
    // Nothing to do: demo
  }

  @Then("the scenario passes")
  public void theScenarioPasses() {
    // Nothing to do: demo
  }
}

📚 Any additional context?

#2860
#3004

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions