Toolium can be also used with behave and lettuce tests.
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:
- context.toolium_config: dictionary with Toolium configuration, readed from properties.cfg
- context.driver_wrapper: :ref:`DriverWrapper <driver_wrapper>` instance
- context.driver: Selenium or Appium driver instance
- context.utils: :ref:`Utils <utils>` instance
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
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 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:
- world.toolium_config: dictionary with Toolium configuration, readed from properties.cfg
- world.driver_wrapper: :ref:`DriverWrapper <driver_wrapper>` instance
- world.driver: Selenium or Appium driver instance
- world.utils: :ref:`Utils <utils>` instance