0

私たちの部門で使用されたテストケースは、SpiraTeamからTFSに移行されました。SpiraTeamを使用すると、テストケースをフォルダ階層に保存できます。

注文/注文と在庫/注文の送信/テスト1:通常の注文を送信

TFSはこの階層をサポートしていないため、移行プロセス中に、各テストのフォルダー階層をプレーンテキストとしてコピーし、「フォルダー」と呼ばれるTFS作業項目のプレーンテキストフィールドに格納します。

私は、テストケースをこの階層で表示し、そこから編集できるようにする小さなC#アプリに取り組んでいます。

テストケースを表示するために、階層からTreeViewを構築する予定です。

テストケースを取得するためのすべての機能があり、現在アプリ内のWorkItemStoreに保存していますが、2つの問題があります。

  1. この情報をTreeViewに表示するにはどうすればよいですか?再帰的アルゴリズムを使用する必要があることは理解していますが、このトピックに関する調査では、使用する必要のあるプレーンテキストフィールドではなく、実際のWindowsディレクトリからTreeViewを構築する方法についての説明が返されます。.Splitメソッドを使用して、「Folder」フィールドを文字列の配列に分割することから始めました。

  2. TreeViewに情報を取得したら、TreeViewノードは文字列に基づいているように見えるため、TreeViewからの選択に基づいてWorkItemStoreの正しいテストケースに移動するにはどうすればよいですか?上記のパスを例として使用して、ストアからワークアイテムを選択するよりも洗練されたソリューションが必要です。WHERE[タイトル] ='テスト1:通常の注文を送信します'。

おそらく、私の2番目の質問に対する解決策は、これをどのように実装するかを決定するでしょう。そして、私の最初の質問は無関係かもしれません。

これに関するいくつかのポインタをいただければ幸いです。

ありがとう、

アンディ

4

1 に答える 1

1

LinqPad で実行できるサンプル プログラムを次に示します。これは WorkItem (この場合は私が作成したクラス) を取り、それを で分割した後に Path を/たどり、その行に沿って Nodes を作成します。同じコレクション内に同じテキストを持つノードが見つかった場合は、それを使用します。代わりは。

void Main()
{
    //Create a treeview with a root node.
    TreeView tv = new TreeView();
    tv.ShowNodeToolTips = true; //Turn on tooltips for this demo.
    tv.Nodes.Add(new TreeNode("Root"));

    //These may need ordering by path before you start.
    var tfsTestCases = new[]
    {
        new WorkItem { Path = "Module/Feature1/SubFeature1/Test1", WorkItemId = 1, },
        new WorkItem { Path = "Module/Feature1/SubFeature1/Test2", WorkItemId = 2, },
        new WorkItem { Path = "Module/Feature1/SubFeature2/Test1", WorkItemId = 3, },
        new WorkItem { Path = "Module/Feature1/SubFeature2/Test2", WorkItemId = 4, },
        new WorkItem { Path = "Module/Feature2/SubFeature1/Test1", WorkItemId = 5, },
        new WorkItem { Path = "Module/Feature2/SubFeature1/Test2", WorkItemId = 6, },
    };

    //Looping through the test cases...
    foreach (var testCase in tfsTestCases)
    {
        //Start at the root of the tree for each work item.
        TreeNode lastNode = tv.Nodes[0];

        //Loop through each part of the path and create a new node.
        //Use the NodeCollection from the one we just created each time through the loop.
        //This allows the next iteration to "walk down" as it goes.
        foreach (var part in testCase.Path.Split('/'))
            lastNode = AddTreeNode(lastNode.Nodes, part);

        //Set the Tag on the last node in the loop, this is the one with the actual Test Case.
        //You can reference the Tag property of "tv.SelectedNode" to get access to the Work Item. If the Tag is null, then it's not a Test Case.
        lastNode.Tag = testCase;
        lastNode.ToolTipText = testCase.WorkItemId.ToString();  //Set for this DEMO.
    }
    //Display the tree.
    tv.Dump();
}

TreeNode AddTreeNode(TreeNodeCollection nodes, String path)
{
    //Try and find a node in the collection matching the specified pathPath.
    var node = nodes.Cast<TreeNode>().Where(node => node.Text == path).SingleOrDefault();
    //If it's not found, create it and add it to the collection of nodes we just searched.
    if (node == null)
    {
        node = new TreeNode(path);
        nodes.Add(parentNode);
    }
    //We need this later, so pass it back.
    return node;
}

class WorkItem
{
    public String Path { get; set; }
    public Int32 WorkItemId { get; set; }
    //etc.
}
于 2012-07-27T19:21:44.023 に答える