Comments (6)
Actually this also apply with optional capture group (not necessarily within non capture group).
Example:
Given("""^I have the name:\s?(.+)?$""") { (name: String) =>
// Do something
}
(This one might not make much sense but I didn't have a better example in mind)
I think a first step would be to provide a better exception message when this happens.
The proper fix to this issue would be to be able to declare parameters as Option
s which is for now not supported out of the box.
from cucumber-jvm-scala.
Can you map java.util.Optional
to scalas Option
? That should be relatively easy to add to cucumber-expressions
.
from cucumber-jvm-scala.
I guess having the ability to have Java's Optional
supported out of the box as parameters would be enough indeed.
@mpkorstanje Do you mean I should open an issue on cucumber-expressions? I'll be happy to have a look and work on it of course :)
from cucumber-jvm-scala.
I'd start of with the PR straight away. Saves us writing an issue 😄
We keep Cucumber expressions in the mono repo.
https://github.com/cucumber/cucumber/tree/master/cucumber-expressions
You'd have to add a case for Optional
here:
That way when if an Optional<String>
or Optional<Integer>
is used as a type hint the parameter is transformed to either a wrapped value or an empty.
from cucumber-jvm-scala.
The first version of JVM after 6.0.0-RC2 JVM will support optionals
from cucumber-jvm-scala.
Starting Cucumber Scala 6.0.0, it's now possible to have such step definitions:
import java.util.Optional
import io.cucumber.scala.{EN, ScalaDsl}
// Scala 2.13 only, use compat lib or your own converter for 2.12 or 2.11
import scala.jdk.OptionConverters._
class OptionalCaptureGroupsSteps extends ScalaDsl with EN {
Given("""^I have the name:\s?(.+)?$""") { (name: Optional[String]) =>
val option: Option[String] = name.toScala
// Do something
}
}
from cucumber-jvm-scala.
Related Issues (20)
- Cucumber Scala final output shows 0 failures even when a scenario fails HOT 12
- Cucumber 6.2.2 not listing all the failed scenarios at the end of tests run HOT 2
- Be ready for Scala 3 HOT 5
- Action Required: Fix Renovate Configuration
- State management for cucumber-scala + cucumber-piococcontainer HOT 6
- Migrate to GitHub Actions HOT 2
- Alternatives to JacksonDefaultDataTableEntryTransformer HOT 1
- Dependency Dashboard
- Internal documentation is not up-to-date since migration to sbt
- Provide a cucumber-scalatest integration HOT 3
- Automate releases HOT 3
- GPG updates HOT 4
- Use mdoc to provide safe documentation
- Compile with latest Scala 3 version HOT 1
- Fix cross build publication
- UndefinedDataTableTypeException with Boolean HOT 5
- Step containing regex capture group not found HOT 3
- Replace custom TypeTag like implementation with Typeable in Scala 3
- Unable to publish to Sonatype
- The release guide mentions Slack and Twitter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cucumber-jvm-scala.