Best Python code snippet using Testify_python
protractor-xml2html-reporter.js
Source:protractor-xml2html-reporter.js  
1var xmlDocument = require('xmldoc');2var fileSystem = require('fs');3var fs = require('fs-extra');4var filePath = require('path');5var _ = require('lodash');6//stores informatations for every suite7var suitesData = [];8//stores data that is used for the whole report9var report = {10  url:'hello',11  name: '',12  browser: '',13  browserVersion: '',14  platform: '',15  time: new Date(),16  screenshotPath: '',17  modifiedSuiteName: false,18  screenshotsOnlyOnFailure: true,19  screenshotsOnlyOnFailure2: true20};21//stores statistics per one suite22var suite = {23  name: '',24  tests:0,25  failed:0,26  errors:0,27  skipped:0,28  passed:0,29  tests1:0,30  tests2:0,31  failed1:0,32  failed2:0,33  errors1:0,34  errors2:0,35  skipped1:0,36  skipped2:0,37  time:0,38  time1:0,39  time2:0,40};41//stores statistics for all suites42var allSuites = {43  tests: 0,44  failed: 0,45  errors: 0,46  skipped: 0,47  passed: 0,48  totalTime: 0,49  reportAs: 'TestCases'50};51//stores all suites summary (needed for piecharts)52var suitesSummary = {53  suites: 0,54  passed: 0,55  failed: 056};57/** Function: getPath58 * Returns the path to the given file based on passed directory.59 *60 * Parameters:61 *    (String) filename - Filename62 *    (String) (optional) dir - directory to look for given file63 */64function getPath(filename, dir) {65  if (dir) {66    fs.ensureDirSync(dir);67    return filePath.join(dir, filename);68  } else {69    return filePath.join(__dirname, filename);70  }71}72function readFile(filename) {73  return fileSystem.readFileSync(filename, 'utf-8');74}75//time passed in seconds76function getTime(time) {77  var hours = Math.floor(time/3600);78  var minutes = Math.floor(time % 3600/60);79  var seconds = (time % 3600) % 60;80  return hours + 'h ' + minutes + 'min ' + seconds + 's';81}82var HTMLReport = function() {83  var generateSummaries = function(reportXml, report) {84    var count =0;85    var testStartedOn;86    var testCases;87    var totalCasesPerSuite;88	var testCases1;89    var totalCasesPerSuite1;90	var xmlData = fileSystem.readFileSync(reportXml, 'utf8');91    var testResultXml = new xmlDocument.XmlDocument(xmlData);92    var testSuites = testResultXml.childrenNamed('testsuite');93    testStartedOn = testSuites[0].attr.timestamp;94    totalSuites = testSuites.length;95	suitesSummary.suites = testSuites.length;96	97	 98     for (var i=0; i < totalSuites; i=count) {99	     suite.name = testSuites[i].attr.name;100	     suite.tests1 = parseInt(testSuites[i].attr.tests);101	     suite.tests = suite.tests1;102		 suite.failed1 = parseInt(testSuites[i].attr.failures);103		 suite.failed =  suite.failed1;104         suite.errors1 = parseInt(testSuites[i].attr.errors);105		 suite.errors =  suite.errors1;106         suite.skipped1 = parseInt(testSuites[i].attr.skipped);107		 suite.skipped = suite.skipped1;108		 suite.time1= parseInt(testSuites[i].attr.time);109		 suite.time = suite.time1;110		 if (suite.failed > suite.tests) {111             suite.failed = suite.tests;112             }113		 suite.passed = suite.tests - suite.failed - suite.errors - suite.skipped;114		 var p=0;115		 for  (var j=count; j<totalSuites-1; j=count)  {116		   if(testSuites[j].attr.name==testSuites[j+1].attr.name){117			 count=count+1;118			 p=p+1;119			 suite.tests2 = parseInt(testSuites[j+1].attr.tests);120			 suite.failed2 = parseInt(testSuites[j+1].attr.failures);121			 suite.errors2 = parseInt(testSuites[j+1].attr.errors);122			 suite.skipped2 = parseInt(testSuites[j+1].attr.skipped);123			 suite.time2= parseInt(testSuites[j+1].attr.time);124			 suite.tests = suite.tests + suite.tests2;125		     suite.failed =  suite.failed+suite.failed2;126		     suite.errors =  suite.errors + suite.errors2;127		     suite.skipped = suite.skipped+suite.skipped2;128		     suite.time = suite.time + suite.time2;129			 if (suite.failed > suite.tests) {130             suite.failed = suite.tests;131             }132		     suite.passed = suite.tests - suite.failed - suite.errors - suite.skipped;133			// console.log(suite.time);134			 135		 continue;136			}137			else{138				suite.passed=suite.passed+1;139				suite.failed=suite.failed-1;140				//count=count+1;141				break;142		   }143          144		  145		}146	   147		  if (suite.failed > suite.tests) {148             suite.failed = suite.tests;149             suite.passed = 0;150          }151		  152		  var testCasesNames = [];153		  var testCasesNames2 = [];154          var testCasesResults = [];155		  var testCasesResults2 =[];156          var testCasesTimes = [];157		  var testCasesTimes2 = [];158          var testCasesMessages = [];159          var screenshotsNamesOnFailure = [];160          var screenshotsNamesOnFailure2 = [];161		  162		   testCases = testSuites[i].childrenNamed('testcase');163           totalCasesPerSuite = testCases.length;164		 for (var j=0; j<totalCasesPerSuite; j++) {165		  if(testCases[j].firstChild == null) {166          testCasesResults.push('Passed');167        } else if (testCases[j].firstChild.name == 'failure'){168          testCasesResults.push('Failed');169        } else if (testCases[j].firstChild.name == 'skipped'){170          testCasesResults.push('Skipped');171        }172		  testCasesTimes.push(Math.ceil(testCases[j].attr.time));173		  testCasesNames.push(testCases[j].attr.name);174		  175		  if (testCasesResults[j] != 'Failed' && report.screenshotsOnlyOnFailure) {176            screenshotsNamesOnFailure.push('None');177          } else {178           if (report.modifiedSuiteName) {179              screenshotsNamesOnFailure.push(report.browser +'-'+ suite.name.substring(suite.name.indexOf(".")+1) + ' ' + ((testCasesNames2[j]).split('&'))[0]  + '.png');180             //screenshotsNamesOnFailure.push(report.browser +'-'+ testSuites[i].attr.name.substring(testSuites[i].attr.name.indexOf(".")+1) + ' ' + testCasesNames[j] + '.png');181            }182            else {183              screenshotsNamesOnFailure.push(report.browser +'-'+ suite.name + ' ' + ((testCasesNames2[j]).split('&'))[0]  + '.png');184           }185          }186		}		187		if(i < totalSuites-1){188		for(var k=1;k<=p;k++){189	    if (testSuites[i].attr.name==testSuites[i+1].attr.name){190		   testCases1 = testSuites[i+k].childrenNamed('testcase');191           totalCasesPerSuite1 = testCases1.length;192           for (var j=0; j<totalCasesPerSuite1; j++) {193        //get test cases results194           if(testCases1[j].firstChild == null) {195          testCasesResults2.push('Passed');196        } else if (testCases1[j].firstChild.name == 'failure'){197          testCasesResults2.push('Failed');198        } else if (testCases1[j].firstChild.name == 'skipped'){199          testCasesResults2.push('Skipped');200        }201		  testCasesTimes2.push(testCases1[j].attr.time);202		  testCasesNames2.push(testCases1[j].attr.name);203		  204		  205		  if (testCasesResults2[j] != 'Failed' && report.screenshotsOnlyOnFailure) {206            screenshotsNamesOnFailure2.push('None');207          } else {208           if (report.modifiedSuiteName) {209             screenshotsNamesOnFailure2.push(report.browser +'-'+ suite.name.substring(suite.name.indexOf(".")+1) + ' ' + ((testCasesNames2[j]).split('&'))[0]  + '.png');210            }211           else {212              screenshotsNamesOnFailure2.push(report.browser +'-'+ suite.name + ' ' + ((testCasesNames2[j]).split('&'))[0] + '.png');213            }214          }215		  216		  217		  218		}219        }		 220	    }221		testCasesResults = testCasesResults.concat(testCasesResults2); 222		testCasesNames = testCasesNames.concat(testCasesNames2);223		testCasesTimes = testCasesTimes.concat(testCasesTimes2);224		screenshotsNamesOnFailure = screenshotsNamesOnFailure.concat(screenshotsNamesOnFailure2);225		console.log(screenshotsNamesOnFailure);226		}	227		228		229		230		231		232	 suitesData.push({'keyword': 'TestSuite', 'name': suite.name, 'testcases': testCasesNames, 'testcasesresults':testCasesResults, 'testcasestimes': testCasesTimes, 'testcasesmessages': testCasesMessages, 'screenshotsNames':screenshotsNamesOnFailure, 'tests': suite.tests, 'failed': suite.failed, 'errors': suite.errors, 'skipped': suite.skipped, 'passed': suite.passed});233      //total statistics234      allSuites.tests += suite.tests;235      allSuites.failed += suite.failed;236      allSuites.errors += suite.errors;237      allSuites.passed += suite.passed;238      allSuites.skipped += suite.skipped;239      allSuites.totalTime += suite.time;240      //suites summary241      if (suite.failed >0) {242        suitesSummary.failed += 1;243      } else {244        suitesSummary.passed += 1;245      }246		count=count+1; 247      }  248    249      }250      251    252  253this.from = function(reportXml, testConfig) {254    //set report data based on testConfig255    report.name = testConfig.reportTitle || 'Test Execution Report';256    report.screenshotPath = testConfig.screenshotPath || './screenshots';257    report.browser = testConfig.testBrowser || 'unknown';258    report.browserVersion = testConfig.browserVersion || 'unknownBrowser';259    report.modifiedSuiteName = testConfig.modifiedSuiteName || false;260    if (testConfig.screenshotsOnlyOnFailure == undefined) {261      report.screenshotsOnlyOnFailure = true;262    } else {263      report.screenshotsOnlyOnFailure = testConfig.screenshotsOnlyOnFailure;264    }265    // report.platform = testConfig.platform;266    //generate statistics267    var testDetails = generateSummaries(reportXml, report);268    //set report data based on statistics269    allSuites.totalTime = getTime(allSuites.totalTime);270    report.time = report.time.toLocaleString();271    //write to html file272    var testOutputPath = getPath('/' + report.browser + '-test-report.html', testConfig['outputPath'] || './');273    fileSystem.writeFileSync(274      testOutputPath,275      _.template(readFile(getPath('index.tmpl')))({276        styles: readFile(getPath('style.css')),277        report: report,278        allSuites: allSuites,279        suitesSummary: suitesSummary,280        testsuites: _.template(readFile(getPath('testsuites.tmpl')))({281          suitesData: suitesData,282          _: _, suite: suite,283          report: report284        }),285        piechart: readFile(getPath('piechart.js'))286      })287    );288  }289};...protractor-xml2html-reporter_old.js
Source:protractor-xml2html-reporter_old.js  
1var xmlDocument = require('xmldoc');2var fileSystem = require('fs');3var fs = require('fs-extra');4var filePath = require('path');5var _ = require('lodash');6//stores informatations for every suite7var suitesData = [];8//stores data that is used for the whole report9var report = {10  name: '',11  browser: '',12  browserVersion: '',13  platform: '',14  time: new Date(),15  screenshotPath: '',16  modifiedSuiteName: false,17  screenshotsOnlyOnFailure: true,18  screenshotsOnlyOnFailure2: true19};20//stores statistics per one suite21var suite = {22  name: '',23  tests:0,24  failed:0,25  errors:0,26  skipped:0,27  passed:0,28  tests1:0,29  tests2:0,30  failed1:0,31  failed2:0,32  errors1:0,33  errors2:0,34  skipped1:0,35  skipped2:0,36  time:0,37  time1:0,38  time2:0,39};40//stores statistics for all suites41var allSuites = {42  tests: 0,43  failed: 0,44  errors: 0,45  skipped: 0,46  passed: 0,47  totalTime: 0,48  reportAs: 'TestCases'49};50//stores all suites summary (needed for piecharts)51var suitesSummary = {52  suites: 0,53  passed: 0,54  failed: 055};56/** Function: getPath57 * Returns the path to the given file based on passed directory.58 *59 * Parameters:60 *    (String) filename - Filename61 *    (String) (optional) dir - directory to look for given file62 */63function getPath(filename, dir) {64  if (dir) {65    fs.ensureDirSync(dir);66    return filePath.join(dir, filename);67  } else {68    return filePath.join(__dirname, filename);69  }70}71function readFile(filename) {72  return fileSystem.readFileSync(filename, 'utf-8');73}74//time passed in seconds75function getTime(time) {76  var hours = Math.floor(time/3600);77  var minutes = Math.floor(time % 3600/60);78  var seconds = (time % 3600) % 60;79  return hours + 'h ' + minutes + 'min ' + seconds + 's';80}81var HTMLReport = function() {82  var generateSummaries = function(reportXml, report) {83    var count =0;84    var testStartedOn;85    var testCases;86    var totalCasesPerSuite;87	var testCases1;88    var totalCasesPerSuite1;89	var xmlData = fileSystem.readFileSync(reportXml, 'utf8');90    var testResultXml = new xmlDocument.XmlDocument(xmlData);91    var testSuites = testResultXml.childrenNamed('testsuite');92    testStartedOn = testSuites[0].attr.timestamp;93    totalSuites = testSuites.length;94	suitesSummary.suites = testSuites.length;95	96	 97     for (var i=0; i < totalSuites; i=count) {98	     suite.name = testSuites[i].attr.name;99	     suite.tests1 = parseInt(testSuites[i].attr.tests);100	     suite.tests = suite.tests1;101		 suite.failed1 = parseInt(testSuites[i].attr.failures);102		 suite.failed =  suite.failed1;103         suite.errors1 = parseInt(testSuites[i].attr.errors);104		 suite.errors =  suite.errors1;105         suite.skipped1 = parseInt(testSuites[i].attr.skipped);106		 suite.skipped = suite.skipped1;107		 suite.time1= parseInt(testSuites[i].attr.time);108		 suite.time = suite.time1;109		 if (suite.failed > suite.tests) {110             suite.failed = suite.tests;111             }112		 suite.passed = suite.tests - suite.failed - suite.errors - suite.skipped;113		 var p=0;114		 for  (var j=count; j<totalSuites-1; j=count)  {115		   if(testSuites[j].attr.name==testSuites[j+1].attr.name){116			 count=count+1;117			 p=p+1;118			 suite.tests2 = parseInt(testSuites[j+1].attr.tests);119			 suite.failed2 = parseInt(testSuites[j+1].attr.failures);120			 suite.errors2 = parseInt(testSuites[j+1].attr.errors);121			 suite.skipped2 = parseInt(testSuites[j+1].attr.skipped);122			 suite.time2= parseInt(testSuites[j+1].attr.time);123			 suite.tests = suite.tests + suite.tests2;124		     suite.failed =  suite.failed+suite.failed2;125		     suite.errors =  suite.errors + suite.errors2;126		     suite.skipped = suite.skipped+suite.skipped2;127		     suite.time = suite.time + suite.time2;128			 if (suite.failed > suite.tests) {129             suite.failed = suite.tests;130             }131		     suite.passed = suite.tests - suite.failed - suite.errors - suite.skipped;132			// console.log(suite.time);133			 134		 continue;135			}136			else{137				suite.passed=suite.passed+1;138				suite.failed=suite.failed-1;139				//count=count+1;140				break;141		   }142          143		  144		}145	   146		  if (suite.failed > suite.tests) {147             suite.failed = suite.tests;148             suite.passed = 0;149          }150		  151		  var testCasesNames = [];152		  var testCasesNames2 = [];153          var testCasesResults = [];154		  var testCasesResults2 =[];155          var testCasesTimes = [];156		  var testCasesTimes2 = [];157          var testCasesMessages = [];158          var screenshotsNamesOnFailure = [];159          var screenshotsNamesOnFailure2 = [];160		  161		   testCases = testSuites[i].childrenNamed('testcase');162           totalCasesPerSuite = testCases.length;163		 for (var j=0; j<totalCasesPerSuite; j++) {164		  if(testCases[j].firstChild == null) {165          testCasesResults.push('Passed');166        } else if (testCases[j].firstChild.name == 'failure'){167          testCasesResults.push('Failed');168        } else if (testCases[j].firstChild.name == 'skipped'){169          testCasesResults.push('Skipped');170        }171		  testCasesTimes.push(Math.ceil(testCases[j].attr.time));172		  testCasesNames.push(testCases[j].attr.name);173		  174		  if (testCasesResults[j] != 'Failed' && report.screenshotsOnlyOnFailure) {175            screenshotsNamesOnFailure.push('None');176          } else {177           if (report.modifiedSuiteName) {178              screenshotsNamesOnFailure.push(report.browser +'-'+ suite.name.substring(suite.name.indexOf(".")+1) + ' ' + testCasesNames[j] + '.png');179             //screenshotsNamesOnFailure.push(report.browser +'-'+ testSuites[i].attr.name.substring(testSuites[i].attr.name.indexOf(".")+1) + ' ' + testCasesNames[j] + '.png');180            }181            else {182              screenshotsNamesOnFailure.push(report.browser +'-'+ suite.name + ' ' + testCasesNames[j] + '.png');183           }184          }185		}		186		if(i < totalSuites-1){187		for(var k=1;k<=p;k++){188	    if (testSuites[i].attr.name==testSuites[i+1].attr.name){189		   testCases1 = testSuites[i+k].childrenNamed('testcase');190           totalCasesPerSuite1 = testCases1.length;191           for (var j=0; j<totalCasesPerSuite1; j++) {192        //get test cases results193           if(testCases1[j].firstChild == null) {194          testCasesResults2.push('Passed');195        } else if (testCases1[j].firstChild.name == 'failure'){196          testCasesResults2.push('Failed');197        } else if (testCases1[j].firstChild.name == 'skipped'){198          testCasesResults2.push('Skipped');199        }200		  testCasesTimes2.push(testCases1[j].attr.time);201		  testCasesNames2.push(testCases1[j].attr.name);202		  203		  204		  if (testCasesResults2[j] != 'Failed' && report.screenshotsOnlyOnFailure) {205            screenshotsNamesOnFailure2.push('None');206          } else {207           if (report.modifiedSuiteName) {208             screenshotsNamesOnFailure2.push(report.browser +'-'+ suite.name.substring(suite.name.indexOf(".")+1) + ' ' + testCasesNames2[j] + '.png');209            }210           else {211              screenshotsNamesOnFailure2.push(report.browser +'-'+ suite.name + ' ' + testCasesNames2[j] + '.png');212            }213          }214		  215		  216		  217		}218        }		 219	    }220		testCasesResults = testCasesResults.concat(testCasesResults2); 221		testCasesNames = testCasesNames.concat(testCasesNames2);222		testCasesTimes = testCasesTimes.concat(testCasesTimes2);223		screenshotsNamesOnFailure = screenshotsNamesOnFailure.concat(screenshotsNamesOnFailure2);224		console.log(screenshotsNamesOnFailure);225		}	226		227		228		229		230		231	 suitesData.push({'keyword': 'TestSuite', 'name': suite.name, 'testcases': testCasesNames, 'testcasesresults':testCasesResults, 'testcasestimes': testCasesTimes, 'testcasesmessages': testCasesMessages, 'screenshotsNames':screenshotsNamesOnFailure, 'tests': suite.tests, 'failed': suite.failed, 'errors': suite.errors, 'skipped': suite.skipped, 'passed': suite.passed});232      //total statistics233      allSuites.tests += suite.tests;234      allSuites.failed += suite.failed;235      allSuites.errors += suite.errors;236      allSuites.passed += suite.passed;237      allSuites.skipped += suite.skipped;238      allSuites.totalTime += suite.time;239      //suites summary240      if (suite.failed >0) {241        suitesSummary.failed += 1;242      } else {243        suitesSummary.passed += 1;244      }245		count=count+1; 246      }  247    248      }249      250    251  252this.from = function(reportXml, testConfig) {253    //set report data based on testConfig254    report.name = testConfig.reportTitle || 'Test Execution Report';255    report.screenshotPath = testConfig.screenshotPath || './screenshots';256    report.browser = testConfig.testBrowser || 'unknown';257    report.browserVersion = testConfig.browserVersion || 'unknownBrowser';258    report.modifiedSuiteName = testConfig.modifiedSuiteName || false;259    if (testConfig.screenshotsOnlyOnFailure == undefined) {260      report.screenshotsOnlyOnFailure = true;261    } else {262      report.screenshotsOnlyOnFailure = testConfig.screenshotsOnlyOnFailure;263    }264    // report.platform = testConfig.platform;265    //generate statistics266    var testDetails = generateSummaries(reportXml, report);267    //set report data based on statistics268    allSuites.totalTime = getTime(allSuites.totalTime);269    report.time = report.time.toLocaleString();270    //write to html file271    var testOutputPath = getPath('/' + report.browser + '-test-report.html', testConfig['outputPath'] || './');272    fileSystem.writeFileSync(273      testOutputPath,274      _.template(readFile(getPath('index.tmpl')))({275        styles: readFile(getPath('style.css')),276        report: report,277        allSuites: allSuites,278        suitesSummary: suitesSummary,279        testsuites: _.template(readFile(getPath('testsuites.tmpl')))({280          suitesData: suitesData,281          _: _, suite: suite,282          report: report283        }),284        piechart: readFile(getPath('piechart.js'))285      })286    );287  }288};...__init__.py
Source:__init__.py  
1"""2Package generated from /System/Library/CoreServices/Finder.app3"""4from warnings import warnpy3k5warnpy3k("In 3.x, the Finder package is removed.", stacklevel=2)6import aetools7Error = aetools.Error8import Standard_Suite9import Legacy_suite10import Containers_and_folders11import Files12import Finder_Basics13import Finder_items14import Window_classes15import Type_Definitions16import Enumerations17_code_to_module = {18    'CoRe' : Standard_Suite,19    'fleg' : Legacy_suite,20    'fndr' : Containers_and_folders,21    'fndr' : Files,22    'fndr' : Finder_Basics,23    'fndr' : Finder_items,24    'fndr' : Window_classes,25    'tpdf' : Type_Definitions,26    'tpnm' : Enumerations,27}28_code_to_fullname = {29    'CoRe' : ('Finder.Standard_Suite', 'Standard_Suite'),30    'fleg' : ('Finder.Legacy_suite', 'Legacy_suite'),31    'fndr' : ('Finder.Containers_and_folders', 'Containers_and_folders'),32    'fndr' : ('Finder.Files', 'Files'),33    'fndr' : ('Finder.Finder_Basics', 'Finder_Basics'),34    'fndr' : ('Finder.Finder_items', 'Finder_items'),35    'fndr' : ('Finder.Window_classes', 'Window_classes'),36    'tpdf' : ('Finder.Type_Definitions', 'Type_Definitions'),37    'tpnm' : ('Finder.Enumerations', 'Enumerations'),38}39from Standard_Suite import *40from Legacy_suite import *41from Containers_and_folders import *42from Files import *43from Finder_Basics import *44from Finder_items import *45from Window_classes import *46from Type_Definitions import *47from Enumerations import *48def getbaseclasses(v):49    if not getattr(v, '_propdict', None):50        v._propdict = {}51        v._elemdict = {}52        for superclassname in getattr(v, '_superclassnames', []):53            superclass = eval(superclassname)54            getbaseclasses(superclass)55            v._propdict.update(getattr(superclass, '_propdict', {}))56            v._elemdict.update(getattr(superclass, '_elemdict', {}))57        v._propdict.update(getattr(v, '_privpropdict', {}))58        v._elemdict.update(getattr(v, '_privelemdict', {}))59import StdSuites60#61# Set property and element dictionaries now that all classes have been defined62#63getbaseclasses(StdSuites.Type_Names_Suite.small_integer)64getbaseclasses(StdSuites.Type_Names_Suite.system_dictionary)65getbaseclasses(StdSuites.Type_Names_Suite.color_table)66getbaseclasses(StdSuites.Type_Names_Suite.fixed_point)67getbaseclasses(StdSuites.Type_Names_Suite.string)68getbaseclasses(StdSuites.Type_Names_Suite.type_element_info)69getbaseclasses(StdSuites.Type_Names_Suite.machine_location)70getbaseclasses(StdSuites.Type_Names_Suite.PostScript_picture)71getbaseclasses(StdSuites.Type_Names_Suite.type_property_info)72getbaseclasses(StdSuites.Type_Names_Suite.menu_item)73getbaseclasses(StdSuites.Type_Names_Suite.scrap_styles)74getbaseclasses(StdSuites.Type_Names_Suite.fixed_rectangle)75getbaseclasses(StdSuites.Type_Names_Suite.null)76getbaseclasses(StdSuites.Type_Names_Suite.type_event_info)77getbaseclasses(StdSuites.Type_Names_Suite.rotation)78getbaseclasses(StdSuites.Type_Names_Suite.long_fixed_rectangle)79getbaseclasses(StdSuites.Type_Names_Suite.long_point)80getbaseclasses(StdSuites.Type_Names_Suite.target_id)81getbaseclasses(StdSuites.Type_Names_Suite.type_suite_info)82getbaseclasses(StdSuites.Type_Names_Suite.type_parameter_info)83getbaseclasses(StdSuites.Type_Names_Suite.long_fixed_point)84getbaseclasses(StdSuites.Type_Names_Suite.bounding_rectangle)85getbaseclasses(StdSuites.Type_Names_Suite.TIFF_picture)86getbaseclasses(StdSuites.Type_Names_Suite.long_fixed)87getbaseclasses(StdSuites.Type_Names_Suite.version)88getbaseclasses(StdSuites.Type_Names_Suite.RGB16_color)89getbaseclasses(StdSuites.Type_Names_Suite.double_integer)90getbaseclasses(StdSuites.Type_Names_Suite.location_reference)91getbaseclasses(StdSuites.Type_Names_Suite.point)92getbaseclasses(StdSuites.Type_Names_Suite.application_dictionary)93getbaseclasses(StdSuites.Type_Names_Suite.unsigned_integer)94getbaseclasses(StdSuites.Type_Names_Suite.menu)95getbaseclasses(StdSuites.Type_Names_Suite.small_real)96getbaseclasses(StdSuites.Type_Names_Suite.fixed)97getbaseclasses(StdSuites.Type_Names_Suite.type_class_info)98getbaseclasses(StdSuites.Type_Names_Suite.RGB96_color)99getbaseclasses(StdSuites.Type_Names_Suite.dash_style)100getbaseclasses(StdSuites.Type_Names_Suite.pixel_map_record)101getbaseclasses(StdSuites.Type_Names_Suite.extended_real)102getbaseclasses(StdSuites.Type_Names_Suite.long_rectangle)103getbaseclasses(process)104getbaseclasses(application_process)105getbaseclasses(desk_accessory_process)106getbaseclasses(application)107getbaseclasses(trash_2d_object)108getbaseclasses(desktop_2d_object)109getbaseclasses(container)110getbaseclasses(folder)111getbaseclasses(disk)112getbaseclasses(application)113getbaseclasses(alias_file)114getbaseclasses(package)115getbaseclasses(file)116getbaseclasses(application_file)117getbaseclasses(internet_location_file)118getbaseclasses(document_file)119getbaseclasses(clipping)120getbaseclasses(preferences_window)121getbaseclasses(Finder_window)122getbaseclasses(window)123getbaseclasses(clipping_window)124getbaseclasses(information_window)125getbaseclasses(item)126getbaseclasses(icon_view_options)127getbaseclasses(preferences)128getbaseclasses(alias_list)129getbaseclasses(icon_family)130getbaseclasses(label)131getbaseclasses(column)132getbaseclasses(list_view_options)133#134# Indices of types declared in this module135#136_classdeclarations = {137    'shor' : StdSuites.Type_Names_Suite.small_integer,138    'aeut' : StdSuites.Type_Names_Suite.system_dictionary,139    'clrt' : StdSuites.Type_Names_Suite.color_table,140    'fpnt' : StdSuites.Type_Names_Suite.fixed_point,141    'TEXT' : StdSuites.Type_Names_Suite.string,142    'elin' : StdSuites.Type_Names_Suite.type_element_info,143    'mLoc' : StdSuites.Type_Names_Suite.machine_location,144    'EPS ' : StdSuites.Type_Names_Suite.PostScript_picture,145    'pinf' : StdSuites.Type_Names_Suite.type_property_info,146    'cmen' : StdSuites.Type_Names_Suite.menu_item,147    'styl' : StdSuites.Type_Names_Suite.scrap_styles,148    'frct' : StdSuites.Type_Names_Suite.fixed_rectangle,149    'null' : StdSuites.Type_Names_Suite.null,150    'evin' : StdSuites.Type_Names_Suite.type_event_info,151    'trot' : StdSuites.Type_Names_Suite.rotation,152    'lfrc' : StdSuites.Type_Names_Suite.long_fixed_rectangle,153    'lpnt' : StdSuites.Type_Names_Suite.long_point,154    'targ' : StdSuites.Type_Names_Suite.target_id,155    'suin' : StdSuites.Type_Names_Suite.type_suite_info,156    'pmin' : StdSuites.Type_Names_Suite.type_parameter_info,157    'lfpt' : StdSuites.Type_Names_Suite.long_fixed_point,158    'qdrt' : StdSuites.Type_Names_Suite.bounding_rectangle,159    'TIFF' : StdSuites.Type_Names_Suite.TIFF_picture,160    'lfxd' : StdSuites.Type_Names_Suite.long_fixed,161    'vers' : StdSuites.Type_Names_Suite.version,162    'tr16' : StdSuites.Type_Names_Suite.RGB16_color,163    'comp' : StdSuites.Type_Names_Suite.double_integer,164    'insl' : StdSuites.Type_Names_Suite.location_reference,165    'QDpt' : StdSuites.Type_Names_Suite.point,166    'aete' : StdSuites.Type_Names_Suite.application_dictionary,167    'magn' : StdSuites.Type_Names_Suite.unsigned_integer,168    'cmnu' : StdSuites.Type_Names_Suite.menu,169    'sing' : StdSuites.Type_Names_Suite.small_real,170    'fixd' : StdSuites.Type_Names_Suite.fixed,171    'gcli' : StdSuites.Type_Names_Suite.type_class_info,172    'tr96' : StdSuites.Type_Names_Suite.RGB96_color,173    'tdas' : StdSuites.Type_Names_Suite.dash_style,174    'tpmm' : StdSuites.Type_Names_Suite.pixel_map_record,175    'exte' : StdSuites.Type_Names_Suite.extended_real,176    'lrct' : StdSuites.Type_Names_Suite.long_rectangle,177    'prcs' : process,178    'pcap' : application_process,179    'pcda' : desk_accessory_process,180    'capp' : application,181    'ctrs' : trash_2d_object,182    'cdsk' : desktop_2d_object,183    'ctnr' : container,184    'cfol' : folder,185    'cdis' : disk,186    'capp' : application,187    'alia' : alias_file,188    'pack' : package,189    'file' : file,190    'appf' : application_file,191    'inlf' : internet_location_file,192    'docf' : document_file,193    'clpf' : clipping,194    'pwnd' : preferences_window,195    'brow' : Finder_window,196    'cwin' : window,197    'lwnd' : clipping_window,198    'iwnd' : information_window,199    'cobj' : item,200    'icop' : icon_view_options,201    'cprf' : preferences,202    'alst' : alias_list,203    'ifam' : icon_family,204    'clbl' : label,205    'lvcl' : column,206    'lvop' : list_view_options,207}208class Finder(Standard_Suite_Events,209        Legacy_suite_Events,210        Containers_and_folders_Events,211        Files_Events,212        Finder_Basics_Events,213        Finder_items_Events,214        Window_classes_Events,215        Type_Definitions_Events,216        Enumerations_Events,217        aetools.TalkTo):218    _signature = 'MACS'219    _moduleName = 'Finder'220    _elemdict = application._elemdict...RooibosSessionInfo.ts
Source:RooibosSessionInfo.ts  
1import type { RooibosConfig } from './RooibosConfig';2import type { TestSuite } from './TestSuite';3import type { TestGroup } from './TestGroup';4import type { TestCase } from './TestCase';5export class SessionInfo {6    public ignoredCount = 0;7    public ignoredTestNames: string[] = [];8    public allTestSuites = new Set<TestSuite>();9    public testSuites = new Map<string, TestSuite>();10    public testSuitesByPath = new Map<string, TestSuite[]>();11    public testSuitesToRun: TestSuite[] = [];12    public hasSoloSuites = false;13    public hasSoloGroups = false;14    public hasSoloTests = false;15    public testsCount = 0;16    public suitesCount = 0;17    public groupsCount = 0;18    public includeTags = [];19    public excludeTags = [];20    constructor(public config: RooibosConfig) {21        for (let tag of config.tags || []) {22            if (tag.startsWith('!')) {23                this.excludeTags.push(tag.substr(1));24            } else {25                this.includeTags.push(tag);26            }27        }28    }29    public updateTestSuites(testSuites: TestSuite[]) {30        //we can assume at this point that all suites coming in belong to same file31        //incase that is useful in future32        for (let testSuite of testSuites) {33            if (testSuite.isValid && !this.isExcludedByTag(testSuite, false)) {34                this.testSuites.set(testSuite.name, testSuite);35                this.addTestSuiteToPath(testSuite);36                if (testSuite.isSolo) {37                    this.hasSoloSuites = !this.hasSoloGroups && !this.hasSoloTests;38                }39                if (testSuite.hasSoloGroups) {40                    this.hasSoloGroups = !this.hasSoloTests;41                }42                if (testSuite.hasSoloTests) {43                    this.hasSoloTests = true;44                    this.hasSoloGroups = false;45                    this.hasSoloSuites = false;46                }47            } else {48                this.allTestSuites.add(testSuite);49            }50        }51        this.suitesCount = this.testSuites.size;52    }53    public addTestSuiteToPath(testSuite: TestSuite) {54        let suites = this.testSuitesByPath.get(testSuite.file.pkgPath) || [];55        //TODO - I think we could end up with duplicate suites in this case..56        suites.push(testSuite);57        this.testSuitesByPath.set(testSuite.file.pkgPath, suites);58    }59    /**60     * Once we know what's ignored/solo/etc, we can ascertain if we're going61     * to include it in the final json payload62     */63    public updateInfo() {64        this.resetCounts();65        for (let testSuite of [...this.testSuites.values()]) {66            if (this.isExcludedByTag(testSuite, false)) {67                testSuite.isIncluded = false;68            } else if (this.hasSoloTests && !testSuite.hasSoloTests) {69                testSuite.isIncluded = false;70            } else if (this.hasSoloSuites && !testSuite.isSolo) {71                testSuite.isIncluded = false;72            } else if (testSuite.isIgnored) {73                testSuite.isIncluded = false;74                this.ignoredTestNames.push(testSuite.name + ' [WHOLE SUITE]');75                this.ignoredCount++;76            } else {77                testSuite.isIncluded = true;78            }79            if (!testSuite.isIncluded) {80                continue;81            }82            //'testSuite  ' + testSuite.name);83            for (let testGroup of testSuite.getTestGroups()) {84                //'GROUP  ' + testGroup.name);85                if (testGroup.isIgnored) {86                    this.ignoredCount += testGroup.ignoredTestCases.length;87                    this.ignoredTestNames.push(testGroup.name + ' [WHOLE GROUP]');88                    testGroup.isIncluded = false;89                } else {90                    if (testGroup.ignoredTestCases.length > 0) {91                        this.ignoredTestNames.push(testGroup.name);92                        this.ignoredCount += testGroup.ignoredTestCases.length;93                        for (let ignoredTestCase of testGroup.ignoredTestCases) {94                            if (!ignoredTestCase.isParamTest) {95                                this.ignoredTestNames.push(ignoredTestCase.name);96                            } else if (ignoredTestCase.paramTestIndex === 0) {97                                let testCaseName = ignoredTestCase.name;98                                if (testCaseName.length > 1 && testCaseName.substr(testCaseName.length - 1) === '0') {99                                    testCaseName = testCaseName.substr(0, testCaseName.length - 1);100                                }101                                this.ignoredTestNames.push(testCaseName);102                            }103                        }104                    }105                    if (this.isExcludedByTag(testGroup, true)) {106                        testGroup.isIncluded = false;107                    } else if (this.hasSoloTests && !testGroup.hasSoloTests) {108                        testGroup.isIncluded = false;109                    } else if (this.hasSoloGroups && !testGroup.isSolo) {110                        testGroup.isIncluded = false;111                    } else {112                        testGroup.isIncluded = true;113                    }114                    if (testGroup.isIncluded) {115                        this.groupsCount++;116                        let testCases = [...testGroup.testCases.values()];117                        for (let testCase of testCases) {118                            if (this.isExcludedByTag(testCase, true)) {119                                testCase.isIncluded = false;120                            } else if (testCase.isIgnored) {121                                testCase.isIncluded = false;122                            } else if (this.hasSoloTests && !testCase.isSolo) {123                                testCase.isIncluded = false;124                            } else {125                                testCase.isIncluded = testGroup.isIncluded || testCase.isSolo;126                                this.testsCount++;127                            }128                        }129                        for (let testCase of testGroup.soloTestCases) {130                            if (this.isExcludedByTag(testCase, true)) {131                                testCase.isIncluded = false;132                            } else {133                                testCase.isIncluded = true;134                                this.testsCount++;135                            }136                        }137                    }138                }139            }140        }141        this.testSuitesToRun = [...this.testSuites.values()].filter((s) => s.isIncluded);142    }143    isExcludedByTag(item: TestCase | TestGroup | TestSuite, isParentIncluded) {144        if (this.excludeTags.length > 0) {145            for (let tag of this.excludeTags) {146                if (item.annotation.tags.has(tag)) {147                    return true;148                }149            }150        }151        if (this.includeTags.length > 0 && (item.annotation.tags.size > 0 || !isParentIncluded)) {152            for (let tag of this.includeTags) {153                if (!item.annotation.tags.has(tag)) {154                    return true;155                }156            }157        }158        return false;159    }160    private resetCounts() {161        this.hasSoloTests = false;162        this.hasSoloGroups = false;163        this.hasSoloSuites = false;164        for (let testSuite of [...this.testSuites.values()]) {165            if (testSuite.isValid && !this.isExcludedByTag(testSuite, false)) {166                if (testSuite.isSolo) {167                    this.hasSoloSuites = !this.hasSoloGroups && !this.hasSoloTests;168                }169                if (testSuite.hasSoloGroups) {170                    this.hasSoloGroups = !this.hasSoloTests;171                }172                if (testSuite.hasSoloTests) {173                    this.hasSoloTests = true;174                    this.hasSoloGroups = false;175                    this.hasSoloSuites = false;176                }177            }178        }179        this.suitesCount = this.testSuites.size;180    }181}182let _sessionInfo: SessionInfo;183export function getSessionInfo(): SessionInfo {184    return _sessionInfo;...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
