Skip to content

Latest commit

 

History

History
111 lines (69 loc) · 3.77 KB

bdd_integration.rst

File metadata and controls

111 lines (69 loc) · 3.77 KB

BDD Integration

Toolium can be also used with behave and lettuce tests.

Behave

Behave tests should be developed as usual, only environment.py file should be modified to initialize driver and the rest of Toolium configuration.

Environment methods should call to the corresponding Toolium environment methods, as can be seen in the following example:

from toolium.behave.environment import (before_all as toolium_before_all, before_scenario as toolium_before_scenario,
                                        after_scenario as toolium_after_scenario, after_all as toolium_after_all)


def before_all(context):
    toolium_before_all(context)


def before_scenario(context, scenario):
    toolium_before_scenario(context, scenario)


def after_scenario(context, scenario):
    toolium_after_scenario(context, scenario)


def after_all(context):
    toolium_after_all(context)

After initialization, the following attributes will be available in behave context:

Behave userdata properties

By default, Toolium configuration is loaded from properties.cfg and local-properties.cfg files. If different properties files are used for different environments, they can be selected using behave user property named env. For example, if env value is android, Toolium configuration will be loaded from properties.cfg, android-properties.cfg and local-android-properties.cfg files:

$ behave -D env=android

Moreover, Toolium properties can be modified from behave userdata configuration. For example, to select the driver type from command line instead of using the driver type defined in properties.cfg:

$ behave -D Driver_type=chrome

Behave tags

Toolium defines some scenario tags to configure Appium tests:

  • @no_reset_app: mobile app will not be reset before test (i.e. no-reset Appium capability is set to true)
  • @reset_app: mobile app will be reset before test (i.e. no-reset and full-reset Appium capabilities are set to false)
  • @full_reset_app: mobile app will be full reset before test (i.e. full-reset Appium capability is set to true)
  • @android_only: identifies a scenario that should only be executed in Android
  • @ios_only: identifies a scenario that should only be executed in iOS

Lettuce

Lettuce tests should be developed as usual, only terrain.py file should be modified to initialize driver and the rest of Toolium configuration.

Terrain methods should call to the corresponding Toolium terrain methods, as can be seen in the following example:

from lettuce import after, before
from toolium.lettuce.terrain import (setup_driver as toolium_setup_driver, teardown_driver as toolium_teardown_driver,
                                     teardown_driver_all as toolium_teardown_driver_all)


@before.each_scenario
def setup_driver(scenario):
    toolium_setup_driver(scenario)


@after.each_scenario
def teardown_driver(scenario):
    toolium_teardown_driver(scenario)


@after.all
def teardown_driver_all(total):
    toolium_teardown_driver_all(total)

After initialization, the following attributes will be available in world object: