background preloader

BDD, TDD & Scaffolding

Facebook Twitter


TDD Tools

ATDD, Cucumber and Scala. Acceptance Test Driven Development (ATDD) is a practice in which the whole team collaboratively discusses acceptance criteria, with examples, and then distills them into a set of concrete acceptance tests before development begins.

ATDD, Cucumber and Scala

If you notice the keywords here then they are whole team discussion acceptance criteria with examples concrete acceptance tests before development begins Hence, just like we do TDD for development, ATDD is an important practice to get your test cases in place before beginning the development of a user story. These acceptance tests are then shown to the stakeholders and the functionality is verified. Changes if any, are made and the development begins. Well, as you guessed you are right in most scenarios. Cucumber separates out the features which the stakeholders understand from the mapping code which binds these features to the corresponding acceptance test code which tests the software functionality. A typical feature file would look like this.

ScaTDD: Casting an eye over three major Test frameworks in Scala. Testing has traditionally been the gateway process for Scala development at a number of Java shops looking to evolve their tech stack with minimal disruption or committment.

ScaTDD: Casting an eye over three major Test frameworks in Scala

This posts hopes to cover three of the main testing frameworks in the Scala landscape, (Specs2, Scalatest and Scalacheck) with an example of the classic FizzBuzz test, for how they can be used for fun and profit. So, the brief outline of the FizzBuzz requirement are that given a sequence of numbers: Any number divisible by 3 should return the String “Fizz”Any number divisible by 5 should return the String “Buzz”Any number divisible by both 3 and 5 should return the String “FizzBuzz”Otherwise the number should be returned as a String In a nutshell A meta framework for writing unit and acceptance tests by specification.

Link Version. ScalaTest. Integrating Cucumber and Play. In this post I want to show you how to integrate Cucumber into a Play (2.2.3) application.

Integrating Cucumber and Play

It assumes some previous Play experience and that you know what Cucumber is about. The example is minimal, but hopefully it is enough to get you started for bigger projects. Let’s start by setting up the SBT plugin. Add to “project/plugins.sbt” the following lines: resolvers += "Templemore Repository" at " addSbtPlugin("templemore" % "sbt-cucumber-plugin" % "0.8.0") This will make it possible for SBT to find and load the plugin. CucumberSettings cucumberFeaturesLocation := ". Note If you ever need to clone the github project and publish locally it could be that Play does not find your local Ivy2 (as it was in my case).

Resolvers += Resolver.file("Local repo", file(System.getProperty("user.home") + "/.ivy2/local"))(Resolver.ivyStylePatterns) Until now we just added the ability to SBT to find and deal with cucumber files. We’ll be using the snapshot versions, so add: resolvers += "Sonatype-Snapshots" at " Pure Scala BDD made easy with SBT and Cucumber. - Funció Notes. Pure Scala BDD made easy with SBT and Cucumber.

Pure Scala BDD made easy with SBT and Cucumber. - Funció Notes

You may probably already know about BDD and Cucumber. Well, Cucumber allows you to program the steps in your scenario in Ruby… and now in Java and Scala, too. Therefore, I evaluated Cucumber as a BDD solution for an upcoming Scala project. And it did really well, compared to other solutions that were quite more difficult to set up. This post is almost unnecessary. If you want the complete picture, check the example project I just created at Bitbucket: . Ingredients Directions Conclusions There is no excuse to not be using BDD in your Scala projects. Ah! Scaffolding a Play application - Scala for Java Developers [Book] Integrating Cucumber and Play.

Scaffolding - Skinny Framework. Scaffold Generator Skinny has a powerful scaffold generator.

Scaffolding - Skinny Framework

Usage is very simple. # If you're a zsh user, try "noglob . /skinny g scaffold ... " . /skinny g scaffold members member name:String "nickname:String:varchar(64)" birthday:Option[LocalDate] . Now you can use CRUD pages for members resource at Parameters Scaffold command’s parameters are … If an attribute’s {paramType} is an entity type (all unexpected types), the attribute will be converted to association definition. . This command will generate following code: Other associations can be generated with the following convention. It’s also possible to specify namespace for the resource: