2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

TestLinkにNOT検索を追加する

Last updated at Posted at 2014-02-09

はじめに

  • TestLinkを使っている人ならテストケースにキーワードを付けて管理している人も少なくはないはず
  • そこで作ったキーワードでNOT検索ができたらなと思う人もまた少なくないはず
  • なので直接書き足してNOT検索を導入する方法を共有

環境

  • OS : CentOS5.8
  • TestLink : 1.9.7
  • TestLinkの言語 : 日本語

修正箇所

  • ビューの変更
  • OR検索/AND検索ボタンのすぐ後ろにラジオボタンを作成
# locale/ja_JP/strings.txt
$TLS_logical_not = "NOT検索"; # ラジオボタンのテキスト

# lib/plan/planAddTC.php
$gui->keywordsFilterType->options = array('OR'  => 'Or',
                                          'AND' => 'And',
                                          'NOT' => 'Not'); # NOTを追加

# lib/functions/tlTestCaseFilterControl.class.php
$this->filters[$key][$type]['items'] = array('Or'  => lang_get('logical_or'),
                                             'And' => lang_get('logical_and'),
                                             'Not' => lang_get('logical_not')); # Notを追加
  • SQLでNOT検索するクエリを追加
# lib/functions/testproject.class.php
$keyword_filter_not = " keyword_id IN (SELECT id FROM keywords" .
                      " WHERE testproject_id = {$testproject_id})" .
                      " AND testcase_id NOT IN (SELECT testcase_id FROM testcase_keywords" .
                      " WHERE keyword_id IN (" . implode(',',(array)$keyword_id) . "))";

  if($keyword_filter_type == 'And') {
    $sql =  " /* Filter Type = AND */ " .
            " SELECT FOXDOG.testcase_id FROM " .
            " ( SELECT COUNT(testcase_id) AS HITS,testcase_id " .
            "   FROM {$this->tables['testcase_keywords']} " .
            "   WHERE {$keyword_filter} " .
            "   GROUP BY testcase_id ) AS FOXDOG " .
            " WHERE FOXDOG.HITS = " . count($keyword_id );
  } elseif($keyword_filter_type == 'Not') { /** この5行を追加 **/
    $sql =  " /* Filter Type = Not */ " .
            " SELECT DISTINCT testcase_id " .
            " FROM {$this->tables['testcase_keywords']} " .
            " WHERE {$keyword_filter_not} ";
  } else {
    $sql =  " /* Filter Type = OR */ " .
            " SELECT testcase_id " .
            " FROM {$this->tables['testcase_keywords']} " .
            " WHERE {$keyword_filter} ";
  }

~ただの宣伝~

  • 全国のSeleniumer必読
  • Seleniumerといっていますが、Selenium, SauceLabs, Travis, Jenkinsに関するノウハウ書いているのでよかったら参考にしてみてください
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?