A new Jnario release!

28 Apr 2013

I am happy to announce the new Jnario 0.0.4 release! With this release, Jnario is finally compatible to Xtend 2.4. But there is more to this release than just the updated Xtend compatibility.

A new Type System

The type system of Xtend has been rewritten from scratch for Xtend 2.4. In the previous Xtend and Jnario releases, some corner cases could result in compile errors in the generated Java code. These are all fixed now. At the same time, the new type system is a lot faster resulting in shorter build times.

Jnario 0.4.0 is now based on the new type system. It further benefits from the type systems increased flexibility. For example, it is now possible to access extension fields from within nested specs:

describe "Extension in nested example groups" {
  extension Shouter = new Shouter
  describe "nested example group"{
    fact "Hello".shout => "HELLO"
  }
}
The same is true for features, where you can use extension which are defined in Background scenarios:
Feature: Extension fields in Backgrounds

Background: extension Shouter = new Shouter Given a background with extension "Hello".shout => "HELLO"

Scenario: Using the background extension Then we can use the extension "Hello".shout => "HELLO"

Beautiful Test Reports

It has always been possible to generate HTML reports for your specifications written in Jnario. This release adds the possibility to include whether a spec is currently passing or failing. All passing specs will be marked green and all failing specs will be marked red with the failure cause. This makes Jnario reports a great way to communicate the progress of your project with your stakeholders. These reports are generated using Maven. For a full example have a look here. Example report

Define your own Matchers

One feature of Jnario is that you can write more readable assertions using should. It provides a common set of matchers such as be or contains:

"Hello" should not be "World"
#["red", "blue"] should contain "red"

But it is also possible to define your own should matchers. This feature has been available for a while, but was not yet featured in the documentation. You can define your own should matchers by defining a method with the prefix shouldXXXX, which needs to return a boolean value. For example, when we define a method shouldeat:

def should_eat(String animal, String food){
  animal == "Monkey" && food == "Banana"
}

...then we can use eat in our should expressions:

"Monkey" should eat "Banana"
"Monkey" should eat "Rocks" throws AssertionError

Better Maven Integration

This release greatly improves the maven support in Jnario. All you need to do to start a new Jnario project is run:

 mvn archetype:generate                                    \
   -DarchetypeGroupId=org.jnario                           \
   -DarchetypeArtifactId=jnario-archetype                  \
   -DarchetypeVersion=0.4.0                                \
   -DgroupId=org.example                                   \
   -DartifactId=myproject

If you run afterwards:

 mvn test
 mvn org.jnario:report:generate

You can check out the newly generated doc at "target/jnario-doc".

More

@Extends(typeof(MySuperClass))
describe "defining super classes"{
     ...
}
fact "Wait for something"{
  // define wait condition using lambdas 
  waitUntil[1 > 0]
  // configuration options
  waitUntil[
    message = "Custom error message"
    duration = 100
    pollingInterval = 10
    1 > 0
  ]
}