How to use add_testsuite method in autotest

Best Python code snippet using autotest_python

junitparser.py

Source:junitparser.py Github

copy

Full Screen

...152 return len(list(self.__iter__()))153 def __add__(self, other):154 result = JUnitXml()155 for suite in self:156 result.add_testsuite(suite)157 for suite in other:158 result.add_testsuite(suite)159 return result160 def __iadd__(self, other):161 for suite in other:162 self.add_testsuite(suite)163 return self164 def add_testsuite(self, suite):165 self.append(suite)166 def update_statistics(self):167 "Update test count, time, etc."168 time = 0169 tests = failures = errors = 0170 for suite in self:171 suite.update_statistics()172 tests += suite.tests173 failures += suite.failures174 errors += suite.errors175 time += suite.time176 self.tests = tests177 self.failures = failures178 self.errors = errors179 self.time = time180 @classmethod181 def fromfile(cls, filepath):182 tree = etree.parse(filepath)183 root_elem = tree.getroot()184 if root_elem.tag == 'testsuites':185 instance = cls()186 elif root_elem.tag == 'testsuite':187 instance = TestSuite()188 else:189 raise JUnitXmlError("Invalid format.")190 instance._elem = root_elem191 instance.filepath = filepath192 return instance193 def write(self, filepath=None, pretty=False):194 write_xml(self, filepath=filepath, pretty=pretty)195class TestSuite(Element):196 _tag = 'testsuite'197 name = Attr()198 hostname = Attr()199 time = FloatAttr()200 timestamp = Attr()201 tests = IntAttr()202 failures = IntAttr()203 errors = IntAttr()204 skipped = IntAttr()205 def __init__(self, name=None):206 super(TestSuite, self).__init__(self._tag)207 self.name = name208 self.filepath = None209 def __iter__(self):210 return super(TestSuite, self).iterchildren(TestCase)211 def __len__(self):212 return len(list(self.__iter__()))213 def __eq__(self, other):214 def props_eq(props1, props2):215 props1 = list(props1)216 props2 = list(props2)217 if len(props1) != len(props2):218 return False219 props1.sort(key=lambda x: x.name)220 props2.sort(key=lambda x: x.name)221 zipped = zip(props1, props2)222 return all([x == y for x, y in zipped])223 return (self.name == other.name and224 self.hostname == other.hostname and225 self.timestamp == other.timestamp) and \226 props_eq(self.properties(), other.properties())227 def __add__(self, other):228 if self == other:229 # Merge the two suites230 result = deepcopy(self)231 for case in other:232 result.add_testcase(case)233 for suite in other.testsuites():234 result.add_testsuite(suite)235 result.update_statistics()236 else:237 # Create a new test result containing two suites238 result = JUnitXml()239 result.add_testsuite(self)240 result.add_testsuite(other)241 return result242 def __iadd__(self, other):243 if self == other:244 for case in other:245 self.add_testcase(case)246 for suite in other.testsuites():247 self.add_testsuite(suite)248 self.update_statistics()249 return self250 else:251 result = JUnitXml()252 result.filepath = self.filepath253 result.add_testsuite(self)254 result.add_testsuite(other)255 return result256 def remove_testcase(self, testcase):257 for case in self:258 if case == testcase:259 super(TestSuite, self).remove(case)260 def update_statistics(self):261 "Updates test count and test time."262 tests = errors = failures = skipped = 0263 time = 0264 for case in self:265 tests += 1266 if isinstance(case.result, Failure):267 failures += 1268 elif isinstance(case.result, Error):269 errors += 1270 elif isinstance(case.result, Skipped):271 skipped += 1272 if case.time is not None:273 time += case.time274 self.tests = tests275 self.errors = errors276 self.failures = failures277 self.skipped = skipped278 self.time = time279 def add_property(self, name, value):280 props = self.child(Properties)281 if props is None:282 props = Properties()283 self.append(props)284 prop = Property(name, value)285 props.add_property(prop)286 def add_testcase(self, testcase):287 self.append(testcase)288 def add_testsuite(self, suite):289 self.append(suite)290 def properties(self):291 props = self.child(Properties)292 if props is None:293 return294 for prop in props:295 yield prop296 def remove_property(self, property):297 props = self.child(Properties)298 if props is None:299 return300 for prop in props:301 if prop == property:302 props.remove(property)...

Full Screen

Full Screen

TestFlowGenerator.py

Source:TestFlowGenerator.py Github

copy

Full Screen

...107 tm_parameters = self.config.get_parameters(testmethod_name, parameters_selector)108 testmethodparameters += tm_parameters109 self.testmethodparameters_list.append(testmethodparameters)110 return testmethodparameters111 def add_testsuite(self, testsuite_name, testmethod_name='', parameters_selector='', timing=None, level=None,112 pattern_name=None, local_flags=''):113 self.update_testsuite_list(testsuite_name, timing, level, pattern_name, local_flags)114 self.update_testmethod_list(testsuite_name, testmethod_name)115 self.update_testmethodparameters_list(testsuite_name, testmethod_name, parameters_selector)116 def update_prop_list(self, prop_list, prop, value):117 value_index = prop_list.index(prop) + 1118 prop_list[value_index] = value119 return prop_list120 def update_sections(self):121 # Create each section122 testmethod_parameters_section = self.writer.create_testmethodparameters_section(self.testmethodparameters_list)123 testmethods_section = self.writer.create_testmethods_section(self.testmethod_list)124 test_suites_section = self.writer.create_test_suites_section(self.testsuite_list)125 testflow_section = self.writer.create_testflow_section(self.testflow)126 # Update each section to section list127 self.reader.update_section_list(testmethod_parameters_section)128 self.reader.update_section_list(testmethods_section)129 self.reader.update_section_list(test_suites_section)130 self.reader.update_section_list(testflow_section)131 def create_testflow_section(self):132 last_active_node = self.testflow133 active_node = self.testflow134 group_name_list = []135 group_dict = {}136 core_group = None137 for line in self.config.testflow_sequence:138 node_type = line['type']139 if (not node_type.startswith('group#')):140 pattern_name = line['pattern']141 testmethod_name = line['testmethod_name']142 parameters_selector = line['parameters_selector']143 local_flags = line['local_flags']144 testsuite_name = line['testsuite_name']145 timing = self.config.get_timing(line['timing_selector'])146 level = self.config.get_level(line['level_selector'])147 if (node_type == 'run'):148 active_node.add(Run_Node(testsuite_name))149 # Add testsuite150 self.add_testsuite(testsuite_name, testmethod_name, parameters_selector, timing, level, pattern_name,151 local_flags)152 elif (node_type == 'run_and_branch'):153 active_node.add(Run_and_branch_Node(testsuite_name, None, MultiBin_Node()))154 # Add testsuite155 self.add_testsuite(testsuite_name, testmethod_name, parameters_selector, timing, level, pattern_name,156 local_flags)157 elif (node_type == 'suite_group'):158 group_name = get_block_name(testsuite_name) + get_core_name(testsuite_name)159 suite_group = Group_Node(False, group_name)160 suite_group.add(Run_and_branch_Node(testsuite_name, None, MultiBin_Node()))161 active_node.add(suite_group)162 # Add testsuite163 self.add_testsuite(testsuite_name, testmethod_name, parameters_selector, timing, level, pattern_name,164 local_flags)165 elif (node_type == 'core_group_start'):166 group_name = get_core_name(testsuite_name)167 core_group = Group_Node(False, group_name)168 core_group.add(Run_and_branch_Node(testsuite_name, None, MultiBin_Node()))169 # Add testsuite170 self.add_testsuite(testsuite_name, testmethod_name, parameters_selector, timing, level, pattern_name,171 local_flags)172 elif (node_type == 'core_group'):173 core_group.add(Run_and_branch_Node(testsuite_name, None, MultiBin_Node()))174 # Add testsuite175 self.add_testsuite(testsuite_name, testmethod_name, parameters_selector, timing, level, pattern_name,176 local_flags)177 elif (node_type == 'core_group_end'):178 core_group.add(Run_and_branch_Node(testsuite_name, None, MultiBin_Node()))179 active_node.add(core_group)180 # Add testsuite181 self.add_testsuite(testsuite_name, testmethod_name, parameters_selector, timing, level, pattern_name,182 local_flags)183 elif (node_type == 'retest_on_fail'):184 testsuite_name_retest = testsuite_name + self.config.get_config('retest_testsuite_postfix')185 # Add testsuite186 self.add_testsuite(testsuite_name, testmethod_name, parameters_selector, timing, level, pattern_name,187 local_flags)188 # Add retest testsuite189 self.add_testsuite(testsuite_name_retest, testmethod_name, parameters_selector, timing, level,190 pattern_name, local_flags)191 active_node.add(Run_and_branch_Node(testsuite_name, None, \192 Run_and_branch_Node(testsuite_name_retest, None, MultiBin_Node())))193 elif (node_type == 'char_shmoo_on_fail'):194 testsuite_name_vmin = testsuite_name + self.config.get_config('vmin_testsuite_postfix')195 testsuite_name_fmax = testsuite_name + self.config.get_config('fmax_testsuite_postfix')196 testsuite_name_shmoo = testsuite_name + self.config.get_config('shmoo_testsuite_postfix')197 # Add testsuite198 self.add_testsuite(testsuite_name, testmethod_name, parameters_selector, timing, level, pattern_name,199 local_flags)200 # Add vmin/fmax/shmoo testsuite201 self.add_testsuite(testsuite_name_vmin, \202 self.config.get_config('vmin_testmethod'), self.config.get_config('vmin_selector'), \203 timing, level, pattern_name, local_flags)204 self.add_testsuite(testsuite_name_fmax, \205 self.config.get_config('fmax_testmethod'), self.config.get_config('fmax_selector'), \206 timing, level, pattern_name, local_flags)207 self.add_testsuite(testsuite_name_shmoo, \208 self.config.get_config('shmoo_testmethod'), self.config.get_config('shmoo_selector'), \209 timing, level, pattern_name, local_flags)210 run_and_branch = Run_and_branch_Node(testsuite_name, None, None)211 run_and_branch.else_branch \212 .add(Run_Node(testsuite_name_vmin)) \213 .add(Run_Node(testsuite_name_fmax)) \214 .add(Run_Node(testsuite_name_shmoo))215 active_node.add(run_and_branch)216 elif (node_type.startswith('group#')):217 group_name = node_type.lstrip('group#')218 if (group_name not in group_name_list):219 last_active_node = active_node220 new_group = Group_Node(False, group_name)221 group_dict[group_name] = new_group...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful