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

error while importing DB in mysql

I upgraded my local testlink mysql server to 5.5.20, and I was trying to import testlink DB to the new version, I was facing an error

error:

#1100 - Table 'pma_column_info' was not locked with LOCK TABLES

I tried to look for solution for it online, found some people suggesting commenting the following line in PhpMyAdmin config file

$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';

tried this, but the import process with giving this time different error

#1146 - Table 'testlink.pma_tracking' doesn't exist

I tried commenting all Advanced phpMyAdmin features, still the import wasn’t working, with different error this time

I read in some forums that I need to install DB create script for advanced features located in

C:\Program Files (x86)\EasyPHP-5.3.9\modules\phpmyadmin\scripts\create_tables.sql

still I was having errors while importing

I noticed in PhpMyConfig file that there are 2 lines for advanced features user name and password, and the lines were commented, I uncommented these 2 lines, uncommented the advanced features configuration, set the user name and password for the root user, saved the config file, then tried to import, worked perfect

/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'root';
$cfg['Servers'][$i]['controlpass'] = 'password';

Monday, March 19, 2012

Installing Toad for DB2 64 bit while DB2 32 bit client exists

I had to install both 32 bit and 64 bit from DB2 runtime client, I needed to install Toad while I have these clients
Trying to install the Toad 32 bit or the 64 bit, both was giving an error that I can’t install Toad while there is different OS DB2 client existing, so I was stuck.
image
The Toad for DB2 installer has detected an existing 64-bit DB2 envirnoment on your computer. This installation for DB2 includes a 32-bit DB2 client. However, DB2 does not allow both 32-bit and 64-bit DB2 environments to exist on the same computer.
I thought of trying something, it is naïve but it worked Smile, I opened registry, looked for the keys
HKEY_LOCAL_MACHINE\SOFTWARE\IBM
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\IBM
Just renamed the IBM in each key to something else, just removed the last M, to be IB
After that I started the 64 bit Toad setup, and it passed the check for any installed IBM software, after the check was passed, I returned the keys back as it was, just in case the Toad setup is going to write anything to the same Key.
Of course there is another more safe option, to uninstall the DB2 clients, and install Toad, then installing back the clients.

.NET: Displaying the same controls in different tabs on a windows forms application

I was using a tab control in my application, i had some controls in one tab that are common, and should be displayed in all tabs

I did the following to display these controls in all tabs

first I grouped these controls in a GroupBox control, named it for example CommonControldGroupBox

Then in my TabControl, I set the SelectedIndexChanged event to specific function

In this function I added some code to change the parent control of my CommonControldGroupBox control

CommonControldGroupBox .Parent = tabcontrol.TabPages[((TabControl)sender).SelectedIndex];

After running, when I change the tabs, the GroupBox control appears on the same location in all my tabs

IBM DB2: using db2 providers for .NET

I was creating a tool to automate test data creation on db2 database, at the beginning I faced lot’ s of issues to be able to use the IBM DB2 .NET drivers. I have 64 bit OS, when I installed 32 bit client, can be downloaded from here, using the IBM.Data.DB2 was giving initialization errors, even if the target for my tool is x86, it was giving problems

errors I was getting:

SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7, tokens 9.5.0.DEF.2, SOFTWARE\IBM\DB2\InstalledCopies

I then removed the 32  bit version and installed the 64 bit version, can be downloaded from here , this also was giving errors since the target is x86, I guess it was looking for the 32 bit DB2 dlls.

error I was getting

Could not load file or assembly 'IBM.Data.DB2, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Finally, I kept both the the 32 bit and the 64 bit, this worked perfectly, and set the target to x86, when I deployed my application to my colleagues having them installed 32 bit IBM Data Server Driver Package on their 32 bit operating systems, it worked perfectly.

Friday, March 2, 2012

.NET: using enum to populate combo box, and parsing the selected value to the enum

I was creating a simple tool and I wanted to have all my drop downs from Enums, and I wanted to get the selected value

I did it like below

The Enum

public enum Status { Active = 0, Canceled = 3 };

Setting the drop down values from it

cbStatus.DataSource = Enum.GetValues(typeof(Status));

Getting the enum from the selected item

Status status; Enum.TryParse<Status>(cbStatus.SelectedValue.ToString(), out status);

Thursday, March 1, 2012

VS 2010 breakpoint not breaking in form load method

I was playing around with a windows forms application, I have removed some references, edited the designer.cs, changed from .NET4 to 3.5 then to 2 then back to 4, and some other things.

After that I was trying to debug, and added a breakpoint to the onload method, the code wasn’t breaking at it.

Started looking at what might have changed, compared the reference, some reference was missing, like the system.core and Microsoft.CSharp. the system.core cann’t be added manually, it is added automatically by the visual studio, so I edited the .csproj file and added it manually

    <Reference Include="System.Core" />   

Compared project config file, and project settings, all looks fine

Then next I set another breakpoint at the constructor function, that was breaking the execution.

So it seems the onload function is not called somehow.

Going back to the designer.cs, the onload method attaching was deleted from the InitializeComponent() method

Adding the line back, every thing went to normal

this.Load += new System.EventHandler(this.Form1_Load);