Skip to content

Hooks can silently be ignored if body returns an Int #60

Closed
@gaeljw

Description

@gaeljw

Describe the bug
The following hook definition:

Before {
  someMethodThatReturnInt()
}

will NOT define a hook because it will be interpreted as Before(someMethodThatReturnInt()) and a missing body.

This it not exactly a bug but this can be quite confusing for users.

To Reproduce

object MySteps extends ScalaDsl with EN {
  Before {
    println("Before hook")
    1 // Silly but for the reproduction purpose
  }
}

Create a feature file with 2 scenarios and a dumb step definition. Check that the before hook is printed only once.

Expected behavior
I would expect that a warning/error is raised at compile time, or that the body is actually interpreted as the hook body rather than something providing the order of the hook.

Depending on how we can fix that, we will consider other options.

Versions:

  • Cucumber Scala: 5.7.0
  • Scala: 2.12

Additional context

  • To be more confusing, I think it will work as a side effect when hooks are defined in class but not in objects because glue classes are reinstantiated at each scenario while glue objects are not.

  • Other definitions (like ParameterType) should be checked as well..

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions