0

私は次の回答で概説されているスクリプトを使用しました。

Rally API:テストフォルダーとメンバーのテストケースをコピーする方法

便利ですが、私が本当にやりたいのは、テストフォルダ全体を別のプロジェクトに移動することです。これは、Rallyユーザーインターフェイスではほぼ不可能です。Rally Supportによると、UIでこれを行う唯一の方法は次のとおりです。

  • 現在のテストフォルダからテストケースの割り当てを解除します
  • ダッシュボードにカスタムグリッドアプリを設定する
  • カスタムグリッドの一括編集を使用して、テストケースのプロジェクトを更新します
  • 最後に、カスタムグリッドの一括編集を使用して、テストフォルダーを更新します。これで、テストケースのターゲットプロジェクトに移動します。

上記のプロセスは不格好ですが、カスタムグリッド内での一括編集が登場する前よりも簡単になりました。各テストケースを1つずつ確認して編集する前に、非常に手動で時間がかかりました。

ただし、移動する必要のあるテストケースは数千あり、カスタムグリッドには致命的な欠陥があります。クエリの最初の200レコードのみが表示されます。したがって、必要な移動を実行するには、グリッドクエリを段階的に手動で変更する必要があります。これは、テストケースを1つずつ編集するよりもかろうじて優れています。スクリプトを使用して、テストケースを含むテストフォルダーをあるプロジェクトから別のプロジェクトに移動する方法はありますか?あると言ってください。

4

1 に答える 1

0

次のスクリプトはこのタスクを実行します。すべてのテストケースを、FormattedIDで識別されるソーステストフォルダーから、同じくFormattedIDで識別されるターゲットテストフォルダーに移動します。ソーステストフォルダーとターゲットテストフォルダーは、異なるプロジェクトに含めることができます(ただし、同じワークスペース内にある必要があります)。質問で参照されているコピースクリプトと同様に、ターゲットテストフォルダーが存在する必要があります。つまり、ターゲットが見つからない場合、スクリプトはテストフォルダーを作成しません。

Ruby REST Toolkitをインストールして構成する必要がある場合は、次のリンクを参照してください。

開発者ポータル:Ruby用のRally REST API

Github

# Copyright 2002-2012 Rally Software Development Corp. All Rights Reserved.

require 'rally_api'

$my_base_url       = "https://rally1.rallydev.com/slm"
$my_username       = "user@company.com"
$my_password       = "password"
$my_workspace      = "My Workspace"
$my_project        = "My Project"
$wsapi_version     = "1.39"

# Test Folders
$source_test_folder_formatted_id = "TF8"
$target_test_folder_formatted_id = "TF11"

#==================== Make a connection to Rally ====================
config                  = {:base_url => $my_base_url}
config[:username]       = $my_username
config[:password]       = $my_password
config[:workspace]      = $my_workspace
config[:project]        = $my_project
config[:version]        = $wsapi_version

@rally = RallyAPI::RallyRestJson.new(config)

begin

  # Lookup source Test Folder
  source_test_folder_query = RallyAPI::RallyQuery.new()
  source_test_folder_query.type = :testfolder
  source_test_folder_query.fetch = true
  source_test_folder_query.query_string = "(FormattedID = \"" + $source_test_folder_formatted_id + "\")"

  source_test_folder_result = @rally.find(source_test_folder_query)

  # Lookup Target Test Folder
  target_test_folder_query = RallyAPI::RallyQuery.new()
  target_test_folder_query.type = :testfolder
  target_test_folder_query.fetch = true
  target_test_folder_query.query_string = "(FormattedID = \"" + $target_test_folder_formatted_id + "\")"

  target_test_folder_result = @rally.find(target_test_folder_query)

  if source_test_folder_result.total_result_count == 0
    puts "Source Test Folder: " + $source_test_folder_formatted_id + "not found. Exiting."
    exit
  end

  if target_test_folder_result.total_result_count == 0
    puts "Target Test Folder: " + $target_test_folder_formatted_id + "not found. Target must exist before moving."
    exit
  end

  source_test_folder = source_test_folder_result.first()
  target_test_folder = target_test_folder_result.first()

  # Populate full object for both Source and Target Test Folders
  full_source_test_folder = source_test_folder.read
  full_target_test_folder = target_test_folder.read

  # Grab collection of Source Test Cases
  source_test_cases = source_test_folder["TestCases"]

  # Loop through Source Test Cases and Move to Target
  source_test_cases.each do |source_test_case|
    begin

      test_case_to_update = source_test_case.read
      source_test_case_formatted_id = test_case_to_update["FormattedID"]

      target_project = full_target_test_folder["Project"]
      target_project_full_object = target_project.read
      target_project_name = target_project_full_object["Name"]

      source_project = full_source_test_folder["Project"]
      source_project_full_object = source_project.read
      source_project_name = source_project_full_object["Name"]

      puts "Source Project Name: #{source_project_name}"
      puts "Target Project Name: #{target_project_name}"

      # Test if the source project and target project are the same
      source_target_proj_match = source_project_name.eql?(target_project_name)

      # If the target Test Folder is in a different Project, we have to do some homework first:
      # "un-Test Folder" the project
      # Assign the Test Case to the Target Project
      # Assign the Test Case to the Target Test Folder
      if !source_target_proj_match then
        fields = {}
        fields["TestFolder"] = ""
        test_case_updated = @rally.update(:testcase, test_case_to_update.ObjectID, fields) #by ObjectID
        puts "Test Case #{source_test_case_formatted_id} successfully dissociated from: #{$source_test_folder_formatted_id}"

        # Get full object on Target Project and assign Test Case to Target Project
        fields = {}
        fields["Project"] = target_project_full_object
        test_case_updated = @rally.update(:testcase, test_case_to_update.ObjectID, fields) #by ObjectID
        puts "Test Case #{source_test_case_formatted_id} successfully assigned to Project: #{target_project_name}"
      end

      # Change the Test Folder attribute on the Test Case
      fields = {}
      fields["TestFolder"] = target_test_folder
      test_case_updated = @rally.update(:testcase, test_case_to_update.ObjectID, fields) #by ObjectID
      puts "Test Case #{source_test_case_formatted_id} successfully moved to #{$target_test_folder_formatted_id}"
    rescue => ex
      puts "Test Case #{source_test_case_formatted_id} not updated due to error"
      puts ex
    end
  end
end
于 2012-11-18T18:04:30.933 に答える