Skip to content

tisis2/Jnario

 
 

Repository files navigation

Build Status

Overview

Jnario is a framework for writing executable specifications for Java. It provides all the goodness of Xtend while being specifically tailored to writing acceptance and unit tests. It is easy to integrate as Jnario specifications are compiled to plain Java Junit tests. Head over to Jnario.org for more information.

See the release notes for the current version.

Dependencies & Installation

  • Jnario requires at least [Eclipse 3.6]Eclipse 4.6 with [Xtext 2.6]Xtext 2.11 and Xtend 2.6. You can install both from this update site http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/.
  • The latest snapshot verion of Jnario can be installed from the following update site http://www.jnario.org/updates/snapshot/.

Examples

Acceptance Specification

Feature: Addition

  In order to avoid silly mistakes
  As a math idiot
  I want to be told the sum of two numbers
  
  Scenario: Add two numbers
    Calculator calculator = new Calculator()
    Given I have entered "50" into the calculator
      calculator.enter(args.first)
    And I have entered "70" into the calculator
    When I press "add"
      calculator.press(args.first)
    Then the result should be "120" on the screen
      calculator.result => args.first

Unit Specifications

package example

import java.util.Stack
import java.util.EmptyStackException

describe Stack{
  context "empty stack"{
    fact subject.size should be 0
    fact subject.pop throws EmptyStackException
  }
  context "one element"{ 
    before subject.add("element")
    fact subject.size should be 1
    fact "pop decreases size"{
      subject.pop
      subject.size => 0 
    }
    fact "pop removes last element"{
      subject.pop => "element"
      subject.contains("element") => true
    } 
  } 
}

Setting up a development environment

use eclipse oomph and the jnario.setup file in the repository root.

Build

Build with Maven 3 and Tycho. Run the following command in the repository root:

mvn clean install

About

Executable specifications for Java

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 84.4%
  • GAP 10.6%
  • HTML 2.8%
  • Xtend 0.9%
  • Python 0.5%
  • JavaScript 0.4%
  • Other 0.4%