Object Level Behavior Testing Tools for Java / Scala

Is Java or Scala equivalent to Cucumber / SpecFlow ? One possibility is to use a cucumber with JRuby; any others?

+5
source share
6 answers

Take a look at ScalaTest with Feature Spec . ScalaTest Website Specification Specification:

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)
    }
  }
}
+8
source

specs forms " Fit- . , , some it.

, , -, , Scala 2.8.0 .

+6

Fitness, . Specs ScalaTest BDD- ( BDD), Java .

+1

JBehave was rewritten after the cucumber was released so that we could use plain text. Gherkin was not there when we wrote it, so it doesn’t analyze it the same way - it uses tokens instead of regexp, but it will do the same job.

http://jbehave.org

+1
source

All Articles