Coder Social home page Coder Social logo

plumbee / cucumber-as3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from miguelatplumbee/cucumber-as3

0.0 37.0 0.0 2.15 MB

cucumber-as3 lets developers write step definitions in as3 and execute feature tests using cucumber

License: MIT License

ActionScript 78.67% Shell 0.54% CSS 0.15% JavaScript 20.64%

cucumber-as3's Introduction

cucumber-as3

Write step definitions in Actionscript and use them to instrument your cucumber tests.

Cucumber-as3 enables Actionscript developers to write and run functional tests using Gherkin syntax and Cucumber.

Cucumber-as3 is not a reimplementation of cucumber in a different language (such as cucumber-jvm or cucumber-js). Instead, it makes use of cucumber wire protocol to test features against a TestRunner written in AS3.

Usage

Given the following feature written using Gherkin syntax:

# calculator.feature
Feature: how to do some math

Scenario: Adding two numbers
   Given I have entered 3 into the calculator
   And I have entered 1 into the calculator
   When I want it to add
   Then the current value should be 4

and a Calculator written in Actionscript:

public class Calculator {

   public function push(n:Number):void { ... }

   public function divide():Number { ... }

   public function add():Number { ... }

}

you can implement the step definitions required by the test:

public class Calculator_Steps {

   private var _calculator:Calculator;

   [BeforeScenario]
   public function setup() : void {
       _calculator = new Calculator();
   }

   [AfterScenario]
   public function tearDown() : void {
       _calculator = null;
   }

   [Given(/^I have entered (\d+) into the calculator$/g)]
   public function pushNumber( n:Number ) : void {
       _calculator.push(n);
   }

   [When(/^I want it to add$/)]
   public function pressButton(button:String) : void {
       _calculator.add();
   }

   [Then(/^the current value should be (.*)$/)]
   public function checkValue(value:Number) : void {
       assertEquals(value, _calculator.result);
   }
}

Next step is to prepare your TestRunner and execute it as an Air application

public class TestRunner extends Sprite
{
    public function TestRunner () {
        super();

        const runner : CukesTestRunner = new CukesTestRunner();
        runner.stepDefinitions = [Calculator_Steps];
        runner.cucumberPort = 56712;
        runner.run();
    }
}

Finally execute the test using cucumber in a terminal

cucumber calculator.feature

cucumber-as3's People

Contributors

miguelatplumbee avatar

Watchers

 avatar James Cloos avatar  avatar  avatar  avatar Marc Trepanier avatar  avatar Pablo Varela avatar  avatar  avatar Dennis Waldron avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar Piergiorgio Niero avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar Vivek avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.