Is there a Java or Scala equivalent to Cucumber/SpecFlow? One possibility is using Cucumber with JRuby; any others?
Cucumber is a tool that supports Behaviour-Driven Development (BDD) - a software development process that aims to enhance software quality and reduce maintenance costs; ScalaTest: A testing tool in the Scala ecosystem. You can test Scala, Scala. js (JavaScript), and Java code with this tool.
SpecFlow is a BDD Tool for .
ScalaTest is one of the most popular, complete and easy-to-use testing frameworks in the Scala ecosystem. Where ScalaTest differs from other testing tools is its ability to support a number of different testing styles such as XUnit and BDD out of the box.
Take a look at ScalaTest with Feature Spec. Sample feature spec from the ScalaTest website:
import org.scalatest.FeatureSpec
import org.scalatest.GivenWhenThen
import scala.collection.mutable.Stack
class ExampleSpec extends FeatureSpec with GivenWhenThen {
feature("The user can pop an element off the top of the stack") {
info("As a programmer")
info("I want to be able to pop items off the stack")
info("So that I can get them in last-in-first-out order")
scenario("pop is invoked on a non-empty stack") {
given("a non-empty stack")
val stack = new Stack[Int]
stack.push(1)
stack.push(2)
val oldSize = stack.size
when("when pop is invoked on the stack")
val result = stack.pop()
then("the most recently pushed element should be returned")
assert(result === 2)
and("the stack should have one less item than before")
assert(stack.size === oldSize - 1)
}
scenario("pop is invoked on an empty stack") {
given("an empty stack")
val emptyStack = new Stack[String]
when("when pop is invoked on the stack")
then("NoSuchElementException should be thrown")
intercept[NoSuchElementException] {
emptyStack.pop()
}
and("the stack should still be empty")
assert(emptyStack.isEmpty)
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With