Using basicReportinc » History » Version 6
Amber Herold, 04/25/2011 03:31 PM
| 1 | 1 | Amber Herold | h1. Using basicReport.inc |
|---|---|---|---|
| 2 | |||
| 3 | basicReport.inc is a class that can be used to quickly display run information as well as parameters and results. It creates html tables by reading database tables. |
||
| 4 | 6 | Amber Herold | The only input it needs is the expId, jobtype and a database table name. BasicReport is used for reporting results from [[Appion_Testing|automated testing]]. |
| 5 | 1 | Amber Herold | |
| 6 | 4 | Amber Herold | This is a sample file using the class to display a list of all the makestack runs that have occured for the session: |
| 7 | <pre> |
||
| 8 | <?php |
||
| 9 | require_once "inc/basicreport.inc"; |
||
| 10 | |||
| 11 | $expId = $_GET['expId']; |
||
| 12 | |||
| 13 | // Create an instance of the BasicReport class to display all the makestack runs from this session. |
||
| 14 | try { |
||
| 15 | $testSuiteReport = new BasicReport( $expId, "makestack2", "ApStackRunData"); |
||
| 16 | |||
| 17 | if ($testSuiteReport->hasRunData()) { |
||
| 18 | $runDatas =$testSuiteReport->getRunDatas(True); |
||
| 19 | |||
| 20 | // For each testsuite run, set the URL for it's report page and display it's summary info. |
||
| 21 | foreach ($runDatas as $runData) { |
||
| 22 | $runReportPage = 'testsuiterunreport.php?expId='.$expId.'&rId='.$runData['DEF_id']; |
||
| 23 | $summaryTable .= $testSuiteReport->displaySummaryTable($runData, $runReportPage); |
||
| 24 | } |
||
| 25 | |||
| 26 | } else { |
||
| 27 | $summaryTable = "<font color='#cc3333' size='+2'>No Test Run information available</font>\n<hr/>\n"; |
||
| 28 | } |
||
| 29 | |||
| 30 | } catch (Exception $e) { |
||
| 31 | $message = $e->getMessage(); |
||
| 32 | $summaryTable = "<font color='#cc3333' size='+2'>Error creating report page: $message </font>\n"; |
||
| 33 | } |
||
| 34 | |||
| 35 | // Display the standard Appion interface header |
||
| 36 | processing_header("Test Suite Results", "Test Suite Results", $javascript, False); |
||
| 37 | |||
| 38 | // Display the table built by the BasicReport class or errors |
||
| 39 | echo $summaryTable; |
||
| 40 | |||
| 41 | // Display the standard Appion interface footer |
||
| 42 | processing_footer(); |
||
| 43 | ?> |
||
| 44 | </pre> |
||
| 45 | |||
| 46 | 5 | Amber Herold | Here is a sample file using the class to display all the information from a single makestack run: |
| 47 | 1 | Amber Herold | <pre> |
| 48 | <?php |
||
| 49 | |||
| 50 | require_once "inc/basicreport.inc"; |
||
| 51 | |||
| 52 | $expId = $_GET['expId']; |
||
| 53 | $runId = $_GET['rId']; |
||
| 54 | |||
| 55 | try { |
||
| 56 | 2 | Amber Herold | // Create an instance of the BasicReport class using the makeStack jobtype and DB table |
| 57 | 1 | Amber Herold | $testSuiteReport = new BasicReport( $expId, "makestack2", "ApStackRunData"); |
| 58 | |||
| 59 | // Get the run data for the specific test run we are reporting on |
||
| 60 | $runData =$testSuiteReport->getRunData($runId); |
||
| 61 | |||
| 62 | // The jobReportLink provides a link to another page for further information. |
||
| 63 | // If there is no more data to display, this should link back to the current page. |
||
| 64 | // If the 3rd param to displaySummaryTable() is True, sub tables will be parsed and displayed. |
||
| 65 | $jobReportLink = 'testsuiterunreport.php?expId='.$expId.'&rId='.$runData['DEF_id']; |
||
| 66 | $summaryTable = $testSuiteReport->displaySummaryTable($runData, $jobReportLink, True); |
||
| 67 | |||
| 68 | } catch (Exception $e) { |
||
| 69 | 2 | Amber Herold | $message = $e->getMessage(); |
| 70 | 1 | Amber Herold | $summaryTable = "<font color='#cc3333' size='+2'>Error creating report page: $message </font>\n"; |
| 71 | } |
||
| 72 | |||
| 73 | // Display the standard Appion interface header |
||
| 74 | processing_header("MakeStack Run Report","MakeStack Run Report for $runData[stackRunName]"); |
||
| 75 | |||
| 76 | // Display the table built by the BasicReport class or errors |
||
| 77 | echo $summaryTable; |
||
| 78 | |||
| 79 | // Display the standard Appion interface footer |
||
| 80 | processing_footer(); |
||
| 81 | |||
| 82 | ?> |
||
| 83 | </pre> |