// add coverage for more detailed evaluation $req_spec_map[$req_spec_id]['requirements'][$req_id]['tc_counters']['expected_coverage'] = $req_spec_map[$req_spec_id]['requirements'][$req_id]['expected_coverage']; foreach ($req_info['linked_testcases'] as $key => $tc_info) { $tc_id = $tc_info['id']; $req_spec_map[$req_spec_id]['requirements'][$req_id]['tc_counters']['total']++; if (isset($testcases[$tc_id]['exec_status'])) { $status = $testcases[$tc_id]['exec_status']; // if the counters for this status don't exist yet, initialize them with 0 if (!isset($req_spec_map[$req_spec_id]['requirements'][$req_id]['tc_counters'][$status])) { $req_spec_map[$req_spec_id]['requirements'][$req_id]['tc_counters'][$status] = 0; } $req_spec_map[$req_spec_id]['requirements'][$req_id]['tc_counters'][$status]++; } } // evaluate this requirement by configured coverage algorithm $eval = evaluate_req($status_code_map, $req_cfg->coverageStatusAlgorithm, $req_spec_map[$req_spec_id]['requirements'][$req_id]['tc_counters']); $req_spec_map[$req_spec_id]['requirements'][$req_id]['evaluation'] = $eval; if (!isset($req_spec_map[$req_spec_id]['req_counters'][$eval])) { $req_spec_map[$req_spec_id]['req_counters'][$eval] = 0; } $req_spec_map[$req_spec_id]['req_counters'][$eval]++; $req_spec_map[$req_spec_id]['req_counters']['total']++; } } } // last step: build the table if (count($req_spec_map)) { // headers $columns = array(); $columns[] = array('title_key' => 'req_spec_short', 'groupable' => 'true', 'hideable' => 'false', 'hidden' => 'true'); $columns[] = array('title_key' => 'title', 'width' => 100, 'groupable' => 'false', 'type' => 'text');
function calculate($req_spec_map, $args, $tplan_mgr, $tc_ids, $status_code_map, $req_cfg) { // BUGID 3439 $testcases = array(); if (count($tc_ids)) { $filters = array('tcase_id' => $tc_ids); // BUGID 3856 if ($args->platform != 0) { $filters['platform_id'] = $args->platform; } $options = array('last_execution' => true, 'output' => 'map'); $testcases = $tplan_mgr->get_linked_tcversions($args->tplan_id, $filters, $options); } foreach ($req_spec_map as $req_spec_id => $req_spec_info) { $req_spec_map[$req_spec_id]['req_counters'] = array('total' => 0); foreach ($req_spec_info['requirements'] as $req_id => $req_info) { $req_spec_map[$req_spec_id]['requirements'][$req_id]['tc_counters'] = array('total' => 0); // add coverage for more detailed evaluation $req_spec_map[$req_spec_id]['requirements'][$req_id]['tc_counters']['expected_coverage'] = $req_spec_map[$req_spec_id]['requirements'][$req_id]['expected_coverage']; foreach ($req_info['linked_testcases'] as $key => $tc_info) { $tc_id = $tc_info['id']; // BUGID 3964 $req_spec_map[$req_spec_id]['requirements'][$req_id]['tc_counters']['total']++; if (isset($testcases[$tc_id]['exec_status'])) { $status = $testcases[$tc_id]['exec_status']; // if the counters for this status don't exist yet, initialize them with 0 if (!isset($req_spec_map[$req_spec_id]['requirements'][$req_id]['tc_counters'][$status])) { $req_spec_map[$req_spec_id]['requirements'][$req_id]['tc_counters'][$status] = 0; } $req_spec_map[$req_spec_id]['requirements'][$req_id]['tc_counters'][$status]++; // BUGID 3964 //$req_spec_map[$req_spec_id]['requirements'][$req_id]['tc_counters']['total'] ++; } } // evaluate this requirement by configured coverage algorithm $eval = evaluate_req($status_code_map, $req_cfg->coverageStatusAlgorithm, $req_spec_map[$req_spec_id]['requirements'][$req_id]['tc_counters']); $req_spec_map[$req_spec_id]['requirements'][$req_id]['evaluation'] = $eval; if (!isset($req_spec_map[$req_spec_id]['req_counters'][$eval])) { $req_spec_map[$req_spec_id]['req_counters'][$eval] = 0; } $req_spec_map[$req_spec_id]['req_counters'][$eval]++; $req_spec_map[$req_spec_id]['req_counters']['total']++; } } return array($req_spec_map, $testcases); }