Beispiel #1
0
    def start_suite(self, name, attributes):
        
        self.SuitSrc =      BuiltIn().get_variable_value('${SUITE_SOURCE}')
        self.issuetracker = BuiltIn().get_variable_value('${ISSUE_TRACKER}')
        self.logdir =       BuiltIn().get_variable_value('${OUTPUT_DIR}')
        self.RobotLogDir =  BuiltIn().get_variable_value('${ALLURE_OUTPUT_DIR}')

        # Reading the Allure Properties file for the Issue Id regular expression
        # for the Issues and the URL to where the Issues/Test Man links should go.
        seperator = "="
        self.AllurePropPath = self.SuitSrc + '\\allure.properties'
        if os.path.exists(self.AllurePropPath) is True: 
            with open(self.SuitSrc+'\\allure.properties') as f:
                for line in f:
                    if seperator in line:
                        name, value = line.split(seperator, 1)
                        self.AllureProperties.append({name.strip() : value.strip()})
                        if name.strip() == 'allure.issues.id.pattern':
                            self.AllureIssueIdRegEx = value.strip()
        
        # Setting this variable prevents the loading of a Library added Listener.
        # I case the Listener is added via Command Line, the Robot Context is not
        # yet there and will cause an exceptions. Similar section in __init__.
        ListenerList = BuiltIn().get_variable_value('${AllureListenerActive}', False)
        BuiltIn().set_global_variable('${AllureListenerActive}', True)

        # When running a Robot folder, the folder itself is also considered a Suite
        # The full check depends on the availability of all the vars which are 
        # only available when a Robot file has started.
        IsSuiteDirectory = os.path.isdir(self.SuitSrc)
        if(not(IsSuiteDirectory)):
            ''' Check if class received Output Directory Path through initialisation. '''
            if self.allurelogdir is None:
                '''' Check if in the Robot file the variable has been set.'''
                if self.RobotLogDir is not None:
                    self.allurelogdir = self.RobotLogDir
                else:
                    ''' No Path was provided, so using output dir with additional sub folder. '''
                    self.allurelogdir = BuiltIn().get_variable_value('${OUTPUT_DIR}') + "\\Allure"

            self.AllureImplc = AllureImpl(self.allurelogdir)

            
        if attributes.get('doc') is not '':
            description = attributes.get('doc')
        else:
            description = name
        
        self.testsuite = TestSuite(name=name,
                title=name,
                description=description,
                tests=[],
                labels=[],
                start=now())

        return
Beispiel #2
0
    def start_suite(self, name, attributes):

        self.SuitSrc = BuiltIn().get_variable_value('${SUITE_SOURCE}')

        # Reading the Allure Properties file for the Issue Id regular expression
        # for the Issues and the URL to where the Issues/Test Man links should go.
        if (self.AllurePropPath is None):
            self.AllurePropPath = os.path.join(self.SuitSrc,
                                               'allure.properties')

        if os.path.exists(self.AllurePropPath) is True:
            self.AllureProperties = AllureProperties(self.AllurePropPath)
            self.AllureIssueIdRegEx = self.AllureProperties.get_property(
                'allure.issues.id.pattern')

        # Not using &{ALLURE} as this is throwing an error and ${ALLURE} gives the
        # desired dictionary in Allure as well.
        BuiltIn().set_global_variable('${ALLURE}',
                                      self.AllureProperties.get_properties())

        # When running a Robot folder, the folder itself is also considered a Suite
        # The full check depends on the availability of all the vars which are
        # only available when a Robot file has started.

        IsSuiteDirectory = os.path.isdir(self.SuitSrc)
        if (not (IsSuiteDirectory)):
            ''' Check if class received Output Directory Path in the properties file. '''
            if self.AllureProperties.get_property(
                    'allure.cli.logs.xml') is None:
                ''' No Path was provided, so using output dir with additional sub folder. '''
                self.allurelogdir = BuiltIn().get_variable_value(
                    '${OUTPUT_DIR}') + "\\Allure"
            else:
                self.allurelogdir = self.AllureProperties.get_property(
                    'allure.cli.logs.xml')

            self.AllureImplc = AllureImpl(self.allurelogdir)
        ''' Clear the directory but not if run in parallel mode in Pabot'''
        PabotPoolId = BuiltIn().get_variable_value('${PABOTEXECUTIONPOOLID}')
        try:
            if (self.isFirstSuite == True
                    and self.AllureProperties.get_property(
                        'allure.cli.logs.xml.clear') == 'True'
                    and PabotPoolId is None):
                clear_directory(
                    self.AllureProperties.get_property('allure.cli.logs.xml'))
        except Exception as e:
            logger.console(pprint.pformat(e))
        finally:
            self.isFirstSuite = False

        if attributes.get('doc') is not '':
            description = attributes.get('doc')
        else:
            description = name

        self.testsuite = TestSuite(name=name,
                                   title=attributes['longname'],
                                   description=description,
                                   tests=[],
                                   labels=[],
                                   start=now())

        return