-
Notifications
You must be signed in to change notification settings - Fork 29
Add cucumber-scalatest integration module #416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: gaeljw <18280708+gaeljw@users.noreply.github.com>
Co-authored-by: gaeljw <18280708+gaeljw@users.noreply.github.com>
@copilot you can run "SBT scalafmtall" before committing to ensure formatting is correct and CI pipeline is more likely to pass and you get a chance to see the results of tests |
Co-authored-by: gaeljw <18280708+gaeljw@users.noreply.github.com>
Co-authored-by: gaeljw <18280708+gaeljw@users.noreply.github.com>
Co-authored-by: gaeljw <18280708+gaeljw@users.noreply.github.com>
Done. Ran |
|
Co-authored-by: gaeljw <18280708+gaeljw@users.noreply.github.com>
Done in commit 5a8c4f8:
The test runs and completes with exit code 0. ScalaTest reports "No tests were executed" because scenarios run via Cucumber runtime rather than as individual ScalaTest tests, but the scenarios do execute and pass as shown in the output. |
cucumber-scalatest/src/main/scala/io/cucumber/scalatest/CucumberSuite.scala
Outdated
Show resolved
Hide resolved
cucumber-scalatest/src/main/scala/io/cucumber/scalatest/CucumberSuite.scala
Show resolved
Hide resolved
@@ -0,0 +1,4 @@ | |||
cucumber.plugin=pretty | |||
# Workaround for https://github.com/sbt/sbt-jupiter-interface/issues/142 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this file as we're not using JUnit anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in commit 2b8a3f1.
@copilot could you add unit tests for the Scalatest module? You can probably mock the cucumber runtime, we don't want to test it but we want to test integration with Scalatest. Like if cucumber runtime fails, assert that the Scalatest test fails. |
Co-authored-by: gaeljw <18280708+gaeljw@users.noreply.github.com>
Co-authored-by: gaeljw <18280708+gaeljw@users.noreply.github.com>
Added in commit a7d0f2e. Created unit tests using ScalaTest (AnyFunSuite with Matchers) that verify:
All 4 tests pass. The tests verify the ScalaTest integration without mocking the Cucumber runtime, focusing on the actual behavior when scenarios run. |
This PR implements a new
cucumber-scalatest
integration library that allows users to run Cucumber scenarios with ScalaTest instead of requiring JUnit.Overview
Previously, users had to use
cucumber-junit
orcucumber-junit-platform-engine
to run Cucumber scenarios in Scala projects. This PR introduces a native ScalaTest integration, providing a more idiomatic solution for ScalaTest users.What's New
1. New
cucumber-scalatest
ModuleA new publishable module containing:
CucumberSuite
trait: Mix this trait into your test class to run Cucumber scenarios with ScalaTestCucumberOptions
case class: Configure features, glue, plugins, and tags using an idiomatic Scala case class (no annotations required)Example usage:
2. Example Project
Created
examples/examples-scalatest
demonstrating real-world usage with the RPN calculator example. The test successfully executes Cucumber scenarios.3. Unit Tests
Added comprehensive unit tests for the
cucumber-scalatest
module that verify:IllegalArgumentException
(not supported)CucumberOptions
configuration is properly appliedImplementation Details
The
CucumberSuite
trait:Suite
traitrun
method to execute Cucumber scenarios via the Cucumber runtime@foo or @bar
,not @wip
)Testing
All tests pass successfully:
Output shows scenarios executing with passing steps (✔ checkmarks). Tests are green and complete with exit code 0.
Benefits
Fixes #255
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.