Skip to content

Step implementation

kkott00 edited this page Feb 3, 2013 · 9 revisions

Test workflow

When you open launcher URL in browser it creates window with test dispatcher ecballium. Content of this window is permanent while test is running.
After this ecballium loads the following:

  • Standard step library (lib.js)
  • Feature file with scenarios (simple.feature, name of file is from URL hash)
  • Library (simple.js)
    ecballium compiles feature file and start to execute step from scenario. Before steps execution and after URL navigation ecballium injects script to target (ecballiumbot.js) and it creates singleton objects ecballiumbot. This bot waits on target side command from ecballium. Then step is completed on target side it notify ecballium. If test navigates from the current page ecballiumbot handle this and notify ecballium too.
    Also ecballiumbot contains a set of test helpers.

To define your own step you should define your library file (simple.js for example):

ecballium.register_handlers [
 [/^Do something (.+) with (.*)/,
  /^Execute (.+) on (.*)/,
  /^Make something (.+)/,
  (par1,par2)->
    if some_condition(par1,par2)
      @done('success')
    else
      @done('failed')
 ]
]

ecballium is the singleton instance of framework in opened window.
Method ecballium.register_handlers is used to add new handler to common container.
Argument is the list of step handlers. Step handler contains several JS regular expressions which used for description of step pattern and function as last element in the list. So you can define one function on several different step. It is useful if there are several variant of step description.
Function in handler gets as this instance of ecballiumbot. Method this.done is used to notify ecballium that test step is completed and returns status of execution.

Aliases

ecballiumbot API

  • ecballiumbot.ecb
    The reference to ecballium.instance
Clone this wiki locally