I have some BDD tests for my software, declared in Gherkin and run using Cucumber JVM. The Cucumber JVM tests could be run at any of several levels (layers) of my application: through the front-end (HTML using Testcontainers), through the back-end (JSON over HTTP through the REST API using Testcontainers), through the back-end in a (Spring Boot Test using Java method calls) test harness using a mock HTTP server, or (for some tests) through the service layer (Java method calls).
But of course I want to test all those layers of my application, to some extent. And that means I want to have some duplication of my BDD tests. I don't want to run all the BDD tests at all the levels. And I don't want to test only through the front-end, so it is easier to debug test failures. At some levels I want to do only a few key tests to show that the layers of the application are properly glued together.
If I naively implement some duplicate Cucumber JVM tests, Cucumber will complain about duplicate step definitions. How do I do duplicated tests, without having Cucumber be confused by duplicate step definitions?
This is a distinct problem from reusing step definitions: at different levels, the code for a step is very different. And it is distinct from testing variants of and application, where different build environments use different step definitions.