Showing posts with label testlink. Show all posts
Showing posts with label testlink. Show all posts

Tuesday, July 10, 2012

testlink: Removing columns from Query Metrics report

We wanted to remove 2 columns from the excel version only of the Query Metrics report, the Build and the Time.

I did play with the php code for some while for the file resultsMoreBuilds.php located in lib\results, then I discovered that I can only hide the values.

To hide the whole column, I need to look into the template.

I opened the template file \testlink\gui\templates\results\resultsMoreBuilds.tpl

located the lines for these 2 columns, 6 lines, 2 for the header,

<th>{$tlImages.sort_hint}{$labels.th_build}</th>

<th>{$tlImages.sort_hint}{$labels.th_execution_ts}</th>

and the same header lines for suit summaries

then another 2 lines for the data

<td style="text-align:center;">{$gui->builds_html[$inst.build_id]|escape}</td>

<td style="text-align:center;">{$inst.execution_ts|strip_tags|escape} </td>

In order to hide these columns from the excel only, which has the value of 3, I added if condition before these lines,

{if ($gui->report_type <> 3)}

In order to pass the report type with the gui object, I have modified \testlink\lib\results\resultsMoreBuilds.php, added a line just after this line $gui = initializeGui($db,$args,$date_format_cfg);

I added $gui->report_type = $args->report_type;

For example the first line will be like this

{if ($gui->report_type <> 3)}<th>{$tlImages.sort_hint}{$labels.th_build}</th> {/if}

Applying the same for the rest of the 6 lines, the 2 columns, Build and Time where not displayed in the extracted excel file

If someone wants to hide these columns from all report types, then simply instead of the if condition, just add an comment, like will look like

<!--<th>{$tlImages.sort_hint}{$labels.th_build}</th> {/if}-->

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\custom_config.inc.php

   $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

//$this->load_unassigned_execution_map();

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, E.id as execution_id, E.tester_id as tester_id " .
    "from user_assignments UA " .
    "inner JOIN testplan_tcversions TPTCV ON UA.feature_id = TPTCV.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 E.id = 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

Wednesday, December 7, 2011

testlink: setting up MySQL Daily backup job

We wanted to keep our data safe, so we started taking backups using phpmyadmin, and because of forgetting sometimes, we thought of automating the backup

After doing some search, using the information from this page http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html

I created a batch file, called DailyBackup.bat for example

and wrote the below in the batch file

@ECHO OFF
for /f "tokens=1-4 delims=/ " %%a in ('date/t') do (
set dw=%%a
set mm=%%b
set dd=%%c
set yy=%%d
)

SET bkupdir="path to backup folder"
SET mysqldir="C:\Program Files (x86)\EasyPHP5.3.0\mysql"
SET dbname=testlink

SET dbuser=username

SET password=password

set zip="C:\Program Files (x86)\GnuWin32\bin\gzip.exe"
@ECHO Beginning backup of %dbname%...

%mysqldir%\bin\mysqldump -B %dbname% -u %dbuser% –p%password% | %zip% > %bkupdir%\dbBkup_%dbname%_%dd%%mm%%dw%.sql.gzip

The above batch file needs gzip to be installed

Then I created a scheduled task that runs daily and executes the above batch file

Monday, November 21, 2011

Upgrading testlink, changed test case formatting in exported document when exporting test cases

We had testlink 1.8.4 and we upgraded to 1.9.3, one of the differences we noted is that 1.9.3 test cases now have steps and when doing export for test cases, the test cases in the exported document looked different that we had exported before. we already exported one document with all test cases from 1.8.4 and did lots of changes. and we wanted to have 1.9.3 exported test cases looks the same

I started looking into the code, and found it in file \lib\functions\print.inc.php

    if ($tcInfo[$key] != '')
    {
        $code .= '<tr>' .
                 '<td><span class="label">' . $labels['step_number'] .':</span></td>' .
                 '<td><span class="label">' . $labels['step_actions'] .':</span></td>' .
                 '<td><span class="label">' . $labels['expected_results'] .':</span></td></tr>';
       
        $loop2do = count($tcInfo[$key]);
        for($ydx=0 ; $ydx < $loop2do; $ydx++)
        {
            $code .= '<tr>' .
                     '<td width="5">' .  $tcInfo[$key][$ydx]['step_number'] . '</td>' .
                     '<td>' .  $tcInfo[$key][$ydx]['actions'] . '</td>' .
                     '<td>' .  $tcInfo[$key][$ydx]['expected_results'] . '</td>' .
                     '</tr>';
        }

 

The above code created a table with a column for step number, column for step actions, column for step results, then there is a loop to create rows for each step. We wanted to get ride of step number column and have just one row for with one cell for step details, and another row for expected results, I have changed the code to be like below

    if ($tcInfo[$key] != '')
    {
        $loop2do = count($tcInfo[$key]);
        for($ydx=0 ; $ydx < $loop2do; $ydx++)
        {
            $code .= '<tr><td colspan="' .  $cfg['tableColspan'] . '"><span class="label">' . $labels['step_actions'] . ':</span><br />' .   $tcInfo[$key][$ydx]['actions'] . '</td></tr>' .
                     '<tr><td colspan="' .  $cfg['tableColspan'] . '"><span class="label">' . $labels['expected_results'] . ':</span><br />' .  $tcInfo[$key][$ydx]['expected_results'] . '</td></tr>';
        }

    }

This worked out great, now it looks exactly like test cases we had before

Testlink: Timeout Exception in reports after setting up integration with Bug tracking system

We are using testlink and already did setup for integration with bug tracking system that we are using, trac. While doing testing after this step we found out that some reports are not working and it is giving timeout exception

after digging into the code looking for why this is happening, I found out that there is some loop that is calling the bug tracking system for each bug attached to test case.

The function that is called to get the bug is called get_bugs_for_exec, found in exec.inc.php file

This function is not causing any problem when opening the test cases, it is listing the bugs and getting the bug data from bug tracking system without any problems

To workaround the error I am getting in the reports, I have created another function called get_bugs_for_exec_reports with the same implementation but instead of calling the bug interface to get bug details, I just commented this part and only displayed the bug number, this will be enough for the reports, then in reports files, I changed instead of calling get_bugs_for_exec, I am calling get_bugs_for_exec_reports

files where I have done this change

\lib\functions\results.class.php

\lib\results\resultsByStatus.php

\lib\results\resultsBugs.php

Function:

function get_bugs_for_exec_report(&$db,&$bug_interface,$execution_id)
{
    $tables['execution_bugs'] = DB_TABLE_PREFIX . 'execution_bugs';
    $tables['executions'] = DB_TABLE_PREFIX . 'executions';
    $tables['builds'] = DB_TABLE_PREFIX . 'builds';
   
    $bug_list=array();
    $sql = "SELECT execution_id,bug_id,builds.name AS build_name " .
        "FROM {$tables['execution_bugs']}, {$tables['executions']} executions, " .
        " {$tables['builds']} builds ".
        "WHERE execution_id={$execution_id} " .
        "AND   execution_id=executions.id " .
        "AND   executions.build_id=builds.id " .
        "ORDER BY builds.name,bug_id";
    $map = $db->get_recordset($sql);
   
    // BUGID 3440 - added is_object() check
    if( !is_null($map) && is_object($bug_interface))
    {     
        foreach($map as $elem)
        {
            $bug_list[$elem['bug_id']]['link_to_bts'] = $elem['bug_id'];#$bug_interface->buildViewBugLink($elem['bug_id'],GET_BUG_SUMMARY);
            $bug_list[$elem['bug_id']]['build_name'] = $elem['build_name'];
        }
    }   
    return($bug_list);
}

Thursday, October 27, 2011

Testlink–trac integration

We are using testlink for test case management, and using trac for bug tracking, we were looking for integration between the 2 tools.
I found out there is built in support for different bug tracking tool in testlink, all we need to do is just to enable this integration
The integration work like the following, you can link any execution of test case to one or more bugs, and when viewing these tese cases it will show the bug id, bug status, bug summary. Also when displaying reports, same bug information is displayed
To enable the integration:
1- Go to testlink directory, open the file
2- Look for the line:  $g_interface_bugs = 'NO';
3- Change to $g_interface_bugs = 'TRAC';
4- Save and close
To setup the integration with trac
1- Go to cfg folder
2- open the file trac.cfg.php
3- Update the setting with your trac url
define('BUG_TRACK_DB_HOST', 'http://hostURL/trac/');
4- update the mapping between testlink project and trac project
$g_interface_bugs_project_name_mapping = array(
    'testlink project name' => 'trac project name'
5- Save and close