批量管理测试用例小结 - Testlink 数据表说明

2016-01-10  籽藤 

Testlink 是树形管理测试用例的,树形结构“父子”节点的关系,是靠 nodes_hierarchy 与 node_types 两张表来控制的。通过 node_types 表,你会知道 nodes_hierarchy中,若 node_type_id = 3 表明这是“test case”节点,若 node_type_id = 2 表明那是 “test suite" 节点。


上图是查看 test suite id 最便捷的方式。虽然 testlink 在界面上没有提供批量移动 test cases 到 suite 的功能,但是咱们可以通过直接操作 mysql 数据实现。

update `nodes_hierarchy`

set parent_id = 2363

where node_type_id = 3

and name like 'CheckChargeNotify_%'

还有两张要注意的表,tcversions 和 tcsteps 

  • test case 的 summary 信息存在 tcversions 中。而 tcversions 的 id 字段,源自 nodes_hierarchy 中 node_type_id = 4 的节点 id。也就是说,tcversions 并不是直接与 nodes_hierarchy 中 test case 节点(node_type_id = 3)关联的,而是与某个版本的 test case 节点关联。特定版本 test case (node_type_id = 4)节点的 parent id 才是 node_type_id = 3 的节点 id。

  • tcversions 表 tc_external_id 字段就是 testlink 界面上可用于搜索的 test case id

如果已知某一类 test cases 的 summary 信息,如何批量将它们转移到特定的 suite 中?如下 sql 供参考,它把当前在 test suite id 为 503 下的部分 cases 转移到 id 为 2362 的 test suite 中。

UPDATE

  `nodes_hierarchy` AS a

SET

  a.parent_id = 2362

WHERE

  a.node_type_id = 3 AND a.id in (

  SELECT

    temp.id

  FROM

    (

    SELECT

  n2.id

FROM

  `nodes_hierarchy` AS n

JOIN

  `tcversions` AS t ON t.id = n.id

JOIN

  `nodes_hierarchy` AS n2 ON n.parent_id = n2.id

WHERE

  n.node_type_id = 4 AND t.summary = 'Company' AND n2.parent_id = 503

  ) temp

)

这个 sql 语句看着挺费劲的,如果是 sql server 中,temp 表是可以完全不用的,但是在 mysql 中,如果不用它,就出现 [Err] 1093:You can't specify target table 'xxxx' for update in FROM clause

好吧,原来在 mysql 中,如果你在 select 中使用了这张表,那么在 update 中不能修改同一张表。于是,我用个 temp 规避这个错误。

参考:http://stackoverflow.com/questions/45494/mysql-error-1093-cant-specify-target-table-for-update-in-from-clause


552°/5528 人阅读/0 条评论 发表评论

登录 后发表评论