@@ -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