You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use Cucumber Scala, all your glue code (steps or hooks) has to be defined in **classes** extending both the `ScalaDsl` trait and a language trait.
6
+
7
+
For instance, to use the English flavour:
8
+
```scala
9
+
importio.cucumber.scala.{EN, ScalaDsl}
10
+
11
+
classMyGlueClassextendsScalaDslwithEN {
12
+
13
+
// Here some steps or hooks definitions
14
+
15
+
Given("""I have {int} cucumbers in my belly"""){ (cucumberCount: Int) =>
16
+
// Do something
17
+
}
18
+
19
+
}
20
+
```
21
+
22
+
Cucumber will automatically load all the glue code defined in classes available in the "glue path" (more details in the Run documentation) inheriting `ScalaDsl`.
23
+
24
+
### Using traits
25
+
26
+
You can define glue code in **traits** as well and have a **class** extending the traits you need.
**Note:** using traits can help you split your tests in different groups and provide some steps only to some tests.
45
+
46
+
### Using objects
47
+
48
+
You can also define glue code in **objects**.
49
+
50
+
It's **not recommended** though, because by definition objects are singleton and if your glue code is stateful you will probably have "state conflicts" between your scenarios.
51
+
52
+
## Running Cucumber tests
53
+
54
+
See also the Running Cucumber for Java [documentation](https://docs.cucumber.io/docs/cucumber/api/#running-cucumber).
55
+
56
+
Add the `cucumber-junit` dependency to your project.
0 commit comments