Existe-t-il un équivalent Java ou Scala à Cucumber/SpecFlow? Une possibilité est d'utiliser le concombre avec JRuby; d'autres?Outils de test de comportement au niveau des fonctionnalités pour Java/Scala
Répondre
Jetez un oeil à ScalaTest with Feature Spec. spec fonction échantillon à partir du site ScalaTest:
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)
}
}
}
specs fournit des spécifications alphabétisées avec «forms» pour développer des spécifications de type «Fit». Vous pouvez trouver un post expliquant la logique de celui-ci here, et some examples de what can be done avec it. Notez cependant que la bibliothèque est toujours en mode alpha car je prévois de lui accorder plus d'attention une fois que Scala 2.8.0 sera installé.
JBehave fonctionne très bien avec Scala. Pour un exemple, dans cet article, http://jnb.ociweb.com/jnb/jnbJun2010.html il y a un lien vers un fichier zip qui contient un exemple d'application utilisant JBehave implémenté complètement dans Scala.
Lien direct vers zip: http://www.ociweb.com/jnb/jnbJun2010-scala-bowling.zip
JBehave a été réécrite après concombre a été libéré, afin que nous puissions également utiliser le texte brut. Gherkin n'était pas sorti quand nous l'avons écrit, donc il n'analyse pas exactement la même chose - utilise des jetons au lieu de regexp - mais ça fera le même travail.
Maintenant, vous pouvez utiliser le concombre et définir vos étapes en Java ou Scala pure.
Ici vous avez un tutoriel court et facile sur la façon de l'utiliser dans Scala avec SBT: http://func.io/post/36452127031/pure-scala-bdd-made-easy-with-sbt-and-cucumber.
Peut-être que http://stackoverflow.com/questions/1068785/which-bdd-framework-for-java-do-you-use pourrait être utile. – Mark
Avez-vous regardé les cadres disponibles? Juste pour Scala, ScalaTest prend en charge BDD, et Specs a été conçu avec BDD à l'esprit. Ensuite, il existe une multitude de frameworks de test pour Java. Peut-être que si vous pouviez mieux expliquer vos exigences, il serait plus facile de répondre à cette question. –