Sunday, March 25, 2012

testlink: creating new report: Results per tester

I was asked to create a new report in testlink , to be the same like existing report “Results per Tester per Build” but only for the latest build and to have latest results from previous builds, so for example if a test case was executed in release 1 and passed, and we are now in release 2 and it is not executed in release 2, it will come in the report as passed.

These are the steps I followed to create the report

- Add the new report entry to the testlink config file testlink\

   $tlCfg->reports_list['resultsByTester'] = array(
    'title' => 'link_resultsByTester',
    'url' => 'lib/results/resultsByTester.php',
    'enabled' => 'all',
    'format' => 'format_html,format_xls'

-modify the strings file, add this at the end

$TLS_link_resultsByTester = "Results By Tester";

Also put the string for the report title

$TLS_caption_results_by_tester = "Results by Tester";

$TLS_link_report_by_tester = "Results by Tester";

$TLS_results_by_tester = "Results by Tester";

-Create new template file, a copy from results by tester per build testlink\gui\templates\results\resultsByTesterPerBuild.tpl

new template: testlink\gui\templates\results\resultsByTester.tpl

-Create new report file, a copy from testlink\lib\results\resultsByTesterPerBuild.php to testlink\lib\results\resultsByTester.php

-The file resultsByTester.php calls testlink\lib\functions\build_progress.class.php so I created new one copy from it called testlink\lib\functions\build_progress_latest.class.php

-I modified the build_progress_latest.class.php,

commented the below line in the constructor method


as I am interested only in assigned test cases

changed the call parameters to get_builds to get only active and open

$this->build_set = $this->tplan_mgr->get_builds($this->tplan_id, 1, 1);

Modified the sql in load_assigned_execution_map()

$sql = "SELECT UA.build_id AS build_id, UA.feature_id AS feature_id,UA.user_id as user_id,TPTCV.testplan_id AS testplan_id, TPTCV.tcversion_id AS tcversion_id " .
    ", TPTCV.platform_id AS platform_id, E.status AS status, as execution_id, E.tester_id as tester_id " .
    "from user_assignments UA " .
    "inner JOIN testplan_tcversions TPTCV ON UA.feature_id = " .
    "left join " .
    "(SELECT max(id) as max_execution_id, tcversion_id FROM testlink.executions group by tcversion_id) X on x.tcversion_id = TPTCV.tcversion_id " .
    "left join executions E on = x.max_execution_id " .
    "where UA.build_id = {$build_id} ";       

- In resultsByTester.php, changed the object $progress to the new class build_progress_latest

$progress = new build_progress_latest($db, $args->tplan_id);

Doing the above, the report was displayed with counts of accumulated results, showing only the latest

This was the start, more enhancements can be done on the template of the report and on the report