diff --git a/cucumber-core/src/main/java/io/cucumber/core/runtime/Runtime.java b/cucumber-core/src/main/java/io/cucumber/core/runtime/Runtime.java index 1a17276692..81b189fc1a 100644 --- a/cucumber-core/src/main/java/io/cucumber/core/runtime/Runtime.java +++ b/cucumber-core/src/main/java/io/cucumber/core/runtime/Runtime.java @@ -3,6 +3,7 @@ import io.cucumber.core.eventbus.EventBus; import io.cucumber.core.feature.FeatureParser; import io.cucumber.core.filter.Filters; +import io.cucumber.core.eventbus.UuidGenerator; import io.cucumber.core.gherkin.Feature; import io.cucumber.core.gherkin.Pickle; import io.cucumber.core.logging.Logger; @@ -119,6 +120,7 @@ public static class Builder { private BackendSupplier backendSupplier; private FeatureSupplier featureSupplier; private List additionalPlugins = emptyList(); + private UuidGenerator uuidGenerator; private Builder() { } @@ -142,6 +144,11 @@ public Builder withFeatureSupplier(final FeatureSupplier featureSupplier) { this.featureSupplier = featureSupplier; return this; } + + public Builder withFeatureSupplier(final UuidGenerator uuidGenerator) { + this.uuidGenerator = uuidGenerator; + return this; + } public Builder withAdditionalPlugins(final Plugin... plugins) { this.additionalPlugins = Arrays.asList(plugins); @@ -173,11 +180,15 @@ public Runtime build() { plugins.addPlugin(exitStatus); if (this.eventBus == null) { - final UuidGeneratorServiceLoader uuidGeneratorServiceLoader = new UuidGeneratorServiceLoader( - classLoader, - runtimeOptions); - this.eventBus = new TimeServiceEventBus(Clock.systemUTC(), - uuidGeneratorServiceLoader.loadUuidGenerator()); + UuidGenerator generator; + if (uuidGenerator == null) { + final UuidGeneratorServiceLoader uuidGeneratorServiceLoader = new UuidGeneratorServiceLoader( + classLoader, runtimeOptions); + generator = uuidGeneratorServiceLoader.loadUuidGenerator(); + } else { + generator = uuidGenerator; + } + this.eventBus = new TimeServiceEventBus(Clock.systemUTC(), generator); } final EventBus eventBus = synchronize(this.eventBus);