← Back to team overview

sikuli-driver team mailing list archive

[Question #664616]: Using Sikuli with BDD (Behave or Lettuce)

 

New question #664616 on Sikuli:
https://answers.launchpad.net/sikuli/+question/664616

Hello,

I am an active user of Sikuli !

I use sikuli with python language and I use to run my scripts by calling java -jar sikulix.jar myscript.sikuli

I would like to know if there is a way to use BDD with my Sikuli test scripts instead of unittest.

My script are looking like this:

--- script sample -------------------------------------------------------------------------------------------------

# -*- coding:utf-8 -*-

"""
ok 2/19/2018 - Windows
"""

import unittest
import os
import datetime
import HTMLTestRunner
import testscontext
import applications

class ApplicationsTestCase(unittest.TestCase):

    def setUp(self):
        App.close('Google Chrome')

    def testLaunchChromeWithoutWaiting(self):
        applications.launch_app("google chrome", wait_img=False, timeout=10)

    def testLaunchChromeAndWait(self):
        applications.launch_app("google chrome", wait_img=True, timeout=10)


if __name__ == '__main__':

    tests = unittest.TestLoader().loadTestsFromTestCase(ApplicationsTestCase)
    now = datetime.datetime.now()
    filename = "{}-{}-{}.{}h{}.html".format(
        now.year, now.month, now.day, now.hour, now.minute
    )
    with open(os.path.join(testscontext.outpath, 'test_reports', 'applications_tests', filename), 'w') as rf:
        runner = HTMLTestRunner.HTMLTestRunner(
            stream = rf, description="Unit testing src/applications. Environment: {}.".format(Env.getOS()),
            title="Applications", dirTestScreenshots=os.path.join(testscontext.outpath, 'test_reports', 'applications_tests')
        )
        runner.run(tests)

--- end script --------------------------------------------------------------------------------------------------------

Then can I write something like that instead ?

--- script sample -------------------------------------
Feature: Test Applications launching
  
  Scenario: Launch Google Chrome

    When I launch "Google Chrome"
    Then I shoud see "google chrome menu icon"
--------------------------------------------------------

With steps definitions in another .sikuli/.py module of course.


So the main question is: is sikuli behavior compatible with BDD testing and Jerkhin language ? 
If yes how to implement Behave/Lettuce BDD tests ?


Thanks,
Adrian

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.