A (not so) easy Solution for exporting WITH custom Fields

The release related discussions, plans and questions.
Locked
maahelal
TestLink user
Posts: 1
Joined: Fri Feb 08, 2008 2:20 am

A (not so) easy Solution for exporting WITH custom Fields

Post by maahelal »

Hi every one,
Thank you for the awesome TestLink, I'm not a testing professional but it takes two eyes to see what a great effort this project puts. also the excellent features it provides.

Sorry if this represents a double post but since I couldn't search the forum I thought I'd better double post than not post at all.

Also this solution is suffecient for "ME" in order for it to be really generic so many factors have to be considered including test case versioning etc.

Without any furhter words, trying to solve the "export with custom fields" missing feature many have faced. I gave it a head scratch and that's where I am:

Code: Select all

SELECT
	`nodes_hierarchy`.*,
	`nodes_hierarchy_1`.*,
	`nodes_hierarchy_1`.`node_order`,
	`tcversions`.*,
	`cfield_design_values`.`value`  AS `TEST_CASE_ID`,
	`cfield_design_values_1`.`value` AS `USE_CASE_ID`
FROM
	`nodes_hierarchy` `nodes_hierarchy` 
		INNER JOIN `cfield_design_values` `cfield_design_values_1` 
		ON `nodes_hierarchy`.`id` = `cfield_design_values_1`.`node_id` 
			INNER JOIN `nodes_hierarchy` `nodes_hierarchy_1` 
			ON `nodes_hierarchy`.`id` = `nodes_hierarchy_1`.`parent_id` 
				INNER JOIN `tcversions` `tcversions` 
				ON `nodes_hierarchy_1`.`id` = `tcversions`.`id` 
					INNER JOIN `cfield_design_values` `cfield_design_values` 
					ON `nodes_hierarchy`.`id` = `cfield_design_values`.`node_id` 
WHERE
	(`nodes_hierarchy`.[b]`node_type_id` =3[/b]) AND
	(`cfield_design_values`.[b]`field_id` =1[/b]) AND
	(`cfield_design_values_1`.[b]`field_id` =2[/b]) 
ORDER BY
	`nodes_hierarchy`.`node_type_id` DESC
Now what is this exactly ?
In brief: This is just a query that outputs tabular formatted test cases where the values of the custom fields are made horizontal as tabular fields given the names of what they represent (TEST_CASE_ID for custom field id 1 and USE_CASE_NAME for custom field id=2.

looking closer, you should notice the AS `TEST_CASE_ID`, part, which in my case represents the "meaning" of the value of the field returned from `field_id` =1.

that's to say, I'm doing Joins on the Parent tables to get the "node_id" for which custom field values are recorded, then I perform a LEFT INNER JOIN on the cfield_design_values with the parent table node_hierarcy as many times as the number of the custom fields itself, each join relationship returns the value stored into a record of the table cfield_design_values based on the index of the custom field I wish retrieve.

I KNOW, it's not simple, I don't think non developers can really manage to get it working right away, and I "wish" to promise to provide a more generic and well-explained version of this.

Btw: complexity of the query is derived from the complexity of the datamodel (database design) which has hierarchies and custom fields represented as detailed entity records.

So, what exactly can you do with this, and how can you use it for the time being:
Most (if not all) of us using Testlink have either a LAMP or a WAMP distro, either families of packages come equipped with PHPMYADMIN, which you can fire from the browser, go to your TestLink database,> Query tab > paste the query and get the results (with query customization of course if you wish) then you can make use of PHPMYADMIN excellent exporting features to output to whatever format you like.

Also, Judging on my current priority to documenting testcases of one of my projects, I would probably end up doing a printable report (most likely using JasperReports/iReports) which makes use of this kind of query with the custom fields I have (13 fields in my example) and as soon as I get to a steady state with this ; plus having the time of course, I will keep the post updated.

Hope this helps someone and saves him/her a head scratch
peace out,
fman
Member of TestLink Community
Posts: 3123
Joined: Tue Nov 15, 2005 7:19 am

Post by fman »

Great.
Thanks for your efforts.
Locked