Skip to content

Commit e9b91f9

Browse files
Copilotgaeljw
andcommitted
Working cucumber-scalatest integration - scenarios run successfully
Co-authored-by: gaeljw <18280708+gaeljw@users.noreply.github.com>
1 parent c371913 commit e9b91f9

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

cucumber-scalatest/src/main/scala/io/cucumber/scalatest/CucumberSuite.scala

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,16 @@ trait CucumberSuite extends Suite {
6969
private def buildRuntimeOptions(): io.cucumber.core.options.RuntimeOptions = {
7070
// Try the built-in annotation parser which works with various annotations
7171
val annotationParser = new CucumberOptionsAnnotationParser()
72+
val packageName = getClass.getPackage.getName
73+
val featurePath = "classpath:" + packageName.replace('.', '/')
74+
7275
try {
7376
val annotationOptions = annotationParser.parse(getClass).build()
77+
val options = new RuntimeOptionsBuilder().build(annotationOptions)
7478

7579
// If no features were specified, use convention (classpath:package/name)
76-
val builder = new RuntimeOptionsBuilder()
77-
val options = builder.build(annotationOptions)
78-
79-
// Check if we have features, if not, add the package as convention
8080
if (options.getFeaturePaths().isEmpty) {
81-
val packageName = getClass.getPackage.getName
82-
val featurePath = "classpath:" + packageName.replace('.', '/')
81+
val builder = new RuntimeOptionsBuilder()
8382
builder.addFeature(io.cucumber.core.feature.FeatureWithLines.parse(featurePath))
8483
builder.addGlue(java.net.URI.create("classpath:" + packageName))
8584
builder.build(annotationOptions)
@@ -89,8 +88,6 @@ trait CucumberSuite extends Suite {
8988
} catch {
9089
case _: Exception =>
9190
// If that fails, use convention based on package name
92-
val packageName = getClass.getPackage.getName
93-
val featurePath = "classpath:" + packageName.replace('.', '/')
9491
val builder = new RuntimeOptionsBuilder()
9592
builder.addFeature(io.cucumber.core.feature.FeatureWithLines.parse(featurePath))
9693
builder.addGlue(java.net.URI.create("classpath:" + packageName))

0 commit comments

Comments
 (0)