Example #1
0
/**
 *
 * 根据执行结果生成单元格信息
 * @param unknown_type $caseList
 */
function getTrCase($caseList, $onlyFail, $onlyCoverd)
{
    //$onlyFail 为真时,只显示 fail 的用例
    //$onlyCoverd 为0时,只显示全浏览器覆盖率为0的用例;为1时,只显示全浏览器覆盖率不为0的用例;为其他时,显示所有的用例
    //创建case名对应的单元格
    $totalTrCase = '';
    require_once 'config.php';
    $rowColor = '#B0E0E6';
    //标记行的颜色,单双数行显示的背景颜色不同
    $numBro = count(Config::getBrowserSet($configBrowserSet));
    $averageCov = 0;
    //所有用例的全浏览器覆盖率的平均值(全浏览器覆盖率为0的不计)
    $numCov = 0;
    //全浏览器覆盖率不为0的用例数量
    foreach ($caseList as $casename => $caseDetail) {
        //每一个用例
        $ifFail = false;
        $cnurl = implode('.', explode('_', $casename));
        $trCase = '';
        $totalCov = calTotalCov($caseDetail, $numBro);
        $averageCov += $totalCov;
        $numCov = $totalCov == 0 ? $numCov : $numCov + 1;
        if ($onlyCoverd == 0 && $totalCov != 0 || $onlyCoverd == 1 && $totalCov == 0) {
            //$onlyCoverd 为0时,只显示全浏览器覆盖率为0的用例;为1时,只显示全浏览器覆盖率不为0的用例;
            continue;
        }
        if (!$onlyFail) {
            //对于展示 fail 的用例的列表,不显示全浏览器覆盖率
            $trCase .= "<td title='全浏览器覆盖率'>" . $totalCov . ($totalCov == "_" ? "" : "%") . "</td>";
        }
        foreach ($caseDetail as $br => $infos) {
            //$b为browser名字,$info为详细信息
            $fail = $infos['fail'];
            $ifFail = $fail == 0 ? $ifFail : true;
            $total = $infos['total'];
            $cov = $infos['cov'];
            $color = $fail == 0 ? $rowColor : '#CD5C5C';
            $PercentSign = $cov == '_' ? '' : '%';
            $trCase .= "<td style='background-color:" . $color . "'>" . $cov . $PercentSign . "</td><td style='background-color:" . $color . "'>" . $fail . "</td><td style='background-color:" . $color . "'>" . $total . "</td>";
        }
        $trCase = "<tr style='background-color:{$rowColor}'><td><a href='http://../run.php?case={$cnurl}'>运行</a>{$casename}</td>" . $trCase . "</tr>";
        if (!$onlyFail || $ifFail) {
            $totalTrCase = $totalTrCase . $trCase;
            $rowColor = $rowColor == '#F0FFFF' ? '#B0E0E6' : '#F0FFFF';
        } else {
        }
    }
    $averageCov = number_format($averageCov / $numCov, 1);
    if ($onlyCoverd == 0) {
        $tableContent = $totalTrCase;
    } elseif (!$onlyFail) {
        $tableContent = "<th rowspan='2'>总覆盖率<br>(平均值:" . $averageCov . "%)</th>" . getThBrowser($caseList) . $totalTrCase;
    } else {
        $tableContent = getThBrowser($caseList) . $totalTrCase;
    }
    return $tableContent;
}
Example #2
0
File: runall.php Project: seco/53to
    if (unlink("./coverage/source.js")) {
        echo "成功删除文件:source.js";
    }
}
source();
if (file_exists("covreport.html")) {
    if (unlink("covreport.html")) {
        echo "成功删除覆盖率报告文件: covreport.html<br />\n";
    }
}
if (file_exists("jshintReport.html")) {
    if (unlink("jshintReport.html")) {
        echo "成功删除: jshintReport.html<br />\n";
    }
}
exec("python ../lib/jshunter_1.2.0.1/jshunter_dev/jshunter/hint.py jshintReport.html ../../../_src", $back);
echo "jshint: " . $back . "<br />\n";
/*记录运行时信息*/
$b = array_key_exists('browser', $_GET) ? $_GET['browser'] : 'all';
//if ( array_key_exists( 'cov' , $_GET ) ){
if ($b != 'all') {
    run($b, true);
} else {
    Config::StopAll();
    //添加启动前结束浏览器步骤
    $browsers = array_key_exists('browserSet', $_GET) ? Config::getBrowserSet($_GET['browserSet']) : Config::$BROWSERS;
    foreach ($browsers as $b => $i) {
        run($b);
        sleep(60);
    }
}
Example #3
0
include 'config.php';
$config;
$configs = preg_split('/[&=]/', $_POST['config']);
for ($j = 0; $j < sizeof($configs); $j += 2) {
    //	echo "{$cfg[$i]} {$cfg[$i+1]}\r\n<br />";
    //    if(strcmp($configs[$j],'browserSet')==0){
    $config[$configs[$j]] = $configs[$j + 1];
    //    }
}
report();
$dom = new DOMDocument('1.0', 'utf-8');
$testsuites = $dom->appendChild($dom->createElement('testsuites'));
$dirName = str_replace('/', '_', "report_{$config['filter']}");
foreach (Config::getBrowserSet($configBrowserSet) as $key => $value) {
    $file = $dirName . "/{$key}.xml";
    if (!file_exists($file)) {
        echo "wait for report : {$file}\r\n<br />";
        return;
    }
    //    Config::StopOne($key);
    $xmlDoc = new DOMDocument('1.0', 'utf-8');
    $xmlDoc->load($file);
    $xmlDom = $xmlDoc->documentElement;
    //echo $xmlDom->nodeName;
    $testsuites->appendChild($dom->importNode($xmlDom, true));
}
$dom->save("report.xml");
$browserNum = count(Config::getBrowserSet($configBrowserSet));
require_once 'record.php';
record();
Config::StopAll();