Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 1663 by gunaseel...@gmail.com: custom defined keyword result_should_be not working through robot.api libraries
http://code.google.com/p/robotframework/issues/detail?id=1663

bash]# pybot --version
Robot Framework 2.8.4 (Python 2.5.6 on linux2)

I am generating the robot tests through public api as follows and running the test through suite.run() i have two method mapped to keyword execute and result_should_be but result_should_be method is not executed and simply ignored

from robot.api import TestCaseFile
from robot.api import TestSuite
from robot.api import TestSuiteBuilder
from robot.api import ResultWriter
from robot.api import logger
import Constants
def generateTests(self):
    self.testSuite = TestSuite(Constants.TEST_SUITE_NAME)
self.testSuite.imports.library(Constants.LIBRARY_NAME,args=[self.testdetails])
    self.testSuite.keywords.create('testSuiteSetup', args=[], type='setup')
self.testSuite.keywords.create('testSuiteTeardown', args=[], type='teardown')
    scriptname_list = self.getSASScript()
    if scriptname_list.__len__() == 0:return False
    for script_name in scriptname_list:
      test = self.testSuite.tests.create(script_name)
      test.keywords.create('testCaseSetup',args=[],type='setup')
      test.keywords.create(Constants.KEYWORD_EXECUTE, args=[script_name])
test.keywords.create(Constants.KEYWORD_RESULT_SHOULD_BE,args=[Constants.TEST_PASSED])
      test.keywords.create('testCaseTeardown',args=[],type='teardown')
      logger.console('testKeyword:%s' %test.keywords,newline=True)

Constants.py
KEYWORD_EXECUTE = '''Execute'''
KEYWORD_RESULT_SHOULD_BE = '''Result Should Be'''
TESTSUITE_KEYWORD_SETUP = '''setup'''
TESTSUITE_KEYWORD_TEARDOWN = '''teardown'''
LIBRARY_NAME   = 'CustomLibrary'

CustomLibrary
class CustomLibrary(object):
  ROBOT_LIBRARY_SCOPE = 'GLOBAL'
  def __init__(self,args):
    cfa_log.debug("initializing Custom Library")
    self.toolconfiguration = args
    self._result = self._path =''
    self._client = None
  def testSuiteSetup(self):
    logger.console("Setup:TestSuite Setup",newline=True)
    self._client = XXXX.Client()

  def testSuiteTeardown(self):
    logger.console("Cleanup:TestSuite Teardown",newline=True)

  def testCaseSetup(self):
    current_time = BuiltIn().get_time().replace(' ', '-').replace(':', '-')
    testcase_id = BuiltIn().get_variable_value('${TEST NAME}')
testcase_path = OperatingSystem().join_path(Constants.TEST_LOG_PATH,testcase_id+'/'+current_time)
    OperatingSystem().create_directory(testcase_path)
    logger.console("testcase_path:%s" %testcase_path,newline=True)
testcase_logfile = OperatingSystem().join_path(testcase_path,'/'+testcase_id+'.log')
    testcaselogger = logging.getLogger(Constants.TESTCASE_LOGGER_NAME)
    testcaselogger.setLevel(Constants.LOG_SETTINGS.get(self.loglevel))
    fh = logging.FileHandler(testcase_logfile)
    fh.setLevel(Constants.LOG_SETTINGS.get(self.loglevel))
formatter = logging.Formatter(fmt='%(asctime)s.%(msecs)d - %(message)s',datefmt='%H:%M:%S')
    fh.setFormatter(formatter)
    testcaselogger.addHandler(fh)
logger.console("Test Log Path Configured:%s" %testcase_path,newline=True)

  def testCaseTeardown(self):
    logger.console("cleanup:testcase teardown",newline=True)
    cfa_log.info("cleanup:testcase teardown")

  def execute(self,sasscript_name):
    self._result = self._client.executeTest(script_name,self._path)

  def result_should_be(self,expected):
    # Robot framework doesnt exist this method
    logger.console("\n\n\n",newline=True)
    logger.console("\n\n\n",newline=True)
    logger.console("result_should_be:expected:%s" %expected,newline=True)
logger.console("result_should_be:self._result:%s" %self._result,newline=True)
    if self._result != expected:
      raise AssertionError('%s != %s' % (self._result, expected))

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--

--- You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to