Exemplo n.º 1
0
 /**
  * Retrieve testsuite regression status
  *
  * @return Array
  */
 function getTestsuiteRegression($testSuiteName)
 {
     //@todo Clean up debug stuff
     $testSuiteManager = new TestSuiteManager();
     $testSuite = $testSuiteManager->getTestSuite($testSuiteName);
     $testCasesArray = $testSuite->getTestCases();
     $testCaseManager = new TestCaseManager();
     $regressionArray = array();
     //PDO::setAttribute("PDO::MYSQL_ATTR_USE_BUFFERED_QUERY", true);
     if (!empty($testCasesArray)) {
         foreach ($testCasesArray as $key => $testCaseName) {
             $regression = FALSE;
             $testCase = new TestCase(substr($testCaseName, 0, -3));
             $rspecStructure = $testCase->retrieveRspecStructure();
             foreach ($rspecStructure as $rspeckey => $rspecLabel) {
                 if (!empty($rspecLabel)) {
                     try {
                         unset($result);
                         $sqlString = "SELECT testsuite_id as Testsuite, FROM_UNIXTIME(date) as Date, status as Status FROM testcase_result\n                                         WHERE rspec_label = " . $this->dbHandler->quote($rspecLabel) . " ORDER BY date DESC";
                         $result = $this->dbHandler->query($sqlString);
                         $result->setFetchMode(PDO::FETCH_OBJ);
                         $rows = $result->fetchAll();
                         // echo "<br>".$rspecLabel." :  <br> ----> " ;
                         //echo $rows[0]->testsuite; echo  $rows[1]->Testsuite;
                         if ($rows[0]->Status == ResultManager::STATUS_FAILURE && $rows[1]->Status == ResultManager::STATUS_PASS) {
                             //echo $rows[0]->Date."-+-";
                             //echo $rows[0]->Status."<br>";
                             /*echo $rows[1]->Date."-+-<br>";
                               echo $rows[1]->Status."<br>";*/
                             $regression = TRUE;
                             $regressionArray[$testCaseName][$rspecLabel] = $regression;
                         }
                         //there would be a regression if execution at 'T-1' has Passed Status and execution at 'T' has Failure status
                     } catch (Exception $e) {
                         echo $e->getMessage();
                     }
                 }
             }
         }
     }
     /*if(!empty($testCasesArray)) {
       foreach ($testCasesArray as $key => $testCaseName) {
           $regression = FALSE;
           $testCase = new TestCase(substr($testCaseName, 0, -3));
           $rspecStructure = $testCase->retrieveRspecStructure();
           foreach ($rspecStructure as $rspeckey => $rspecLabel) {
           $lastExec = $testCase->getLastOldExecutionStatusByRspecLabel($rspecLabel);
            echo $rspecLabel." -- ".$lastExec."<br>";
           if(!$lastExec) {
               $regression = TRUE;
               $regressionArray[$testCaseName][$rspecLabel] = $regression;
               }
           }
       }    */
     return $regressionArray;
 }
Exemplo n.º 2
0
 /**
  * Store testCases into DB
  *
  * @param TestCase  $testCase     TestCase to store
  * @param TestSuite $testSuite    Target test suite to populate
  *
  * @return Void
  */
 function storeTestCase($testCase, $testSuite)
 {
     $rspecStructure = $testCase->retrieveRspecStructure();
     $this->dbHandler = DBHandler::getInstance();
     foreach ($rspecStructure as $testString) {
         try {
             $sql = "INSERT INTO testcase (id, filename, rspec_label, testsuite_id) VALUES (" . $this->dbHandler->quote($testCase->id) . ", " . $this->dbHandler->quote($testCase->name) . ", " . $this->dbHandler->quote($testString) . ", " . $this->dbHandler->quote($testSuite->getTestSuiteName()) . ")";
             $this->dbHandler->query($sql);
         } catch (Exception $e) {
             echo $e->getMessage();
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Display test case as HTML output
  *
  * @param String $name     The test case name
  *
  * @return String
  */
 function rspecPrettyFormat($testCaseName)
 {
     $testCaseObj = new TestCase($testCaseName);
     $rspecStructure = $testCaseObj->retrieveRspecStructure();
     $rspecOutput = '<br><pre>ClassName     : ' . $testCaseObj->name . '.rb';
     $rspecOutput .= '<br><br><b>' . count($rspecStructure) . ' Rspec examples:</b> <br><br>';
     foreach ($rspecStructure as $testString) {
         $rspecOutput .= '<span style="padding: 25px;">' . $testString . '</span><br>';
     }
     $rspecOutput .= '<br>';
     $dependencies = $testCaseObj->getDependencies();
     if (!empty($dependencies)) {
         $rspecOutput .= '<b>' . count($dependencies) . ' test(s) in the dependency list</b>:<br><br>';
         foreach ($dependencies as $deps) {
             $rspecOutput .= '<span style="padding: 25px;">' . $deps . '</span><br>';
         }
     }
     $rspecOutput .= '<br></pre>';
     return $rspecOutput;
 }