Azure DevOps Server 2019 Programmatially copy test case error Exception: 'TF237124: Work Item is not ready to save'"。

问题描述 投票:0回答:1

我能够用这段代码复制大多数测试用例(试图复制共享步骤成为测试用例本身的一部分),但这个测试用例将无法复制,但我看不到任何错误信息以说明原因--有谁能建议尝试其他方法。请看立即窗口的输出。谢谢John。

?targetTestCase.Error
null
?targetTestCase.InvalidProperties
Count = 0
?targetTestCase.IsDirty
true
?targetTestCase.State
"Ready"
?targetTestCase.Reason
"New"

foreach (ITestAction step in testSteps)
        {
            if (step is ITestStep)
            {
                ITestStep sourceStep = (ITestStep)step;
                ITestStep targetStep = targetTestCase.CreateTestStep();
                targetStep.Title = sourceStep.Title;
                targetStep.Description = sourceStep.Description;
                targetStep.ExpectedResult = sourceStep.ExpectedResult;

                //Copy Attachments
                if (sourceStep.Attachments.Count > 0)
                {
                    string attachmentRootFolder = _tfsServiceUtilities.GetAttachmentsFolderPath();
                    string testCaseFolder = _tfsServiceUtilities.CreateDirectory(attachmentRootFolder, "TestCase_" + targetTestCase.Id);
                    //Unique folder path for test step
                    string TestStepAttachementFolder = _tfsServiceUtilities.CreateDirectory(testCaseFolder, "TestStep_" + sourceStep.Id);

                    using (var client = new WebClient())
                    {
                        client.UseDefaultCredentials = true;
                        foreach (ITestAttachment attachment in sourceStep.Attachments)
                        {
                            string attachmentPath = TestStepAttachementFolder + "\\" + attachment.Name;
                            client.DownloadFile(attachment.Uri, attachmentPath);
                            ITestAttachment newAttachment = targetTestCase.CreateAttachment(attachmentPath);
                            newAttachment.Comment = attachment.Comment;
                            targetStep.Attachments.Add(newAttachment);
                        }
                    }
                }
                targetTestCase.Actions.Add(targetStep);
                targetTestCase.Save();
            }
azure-devops-rest-api azure-devops-server-2019
1个回答
0
投票

由于这段代码对大多数测试用例都有效,所以这个问题可能来自于特定的测试用例。为了缩小问题的范围,请尝试以下项目。

  1. 在另一台客户机上运行这段代码 看看是否能正常工作
  2. 尝试使用账户API使用来修改这个特定的测试用例,看看是否可以成功保存。
  3. 尝试在保存前验证WorkItem。在保存之前,尝试验证WorkItem。验证() 方法将返回一个无效字段的数组列表。
© www.soinside.com 2019 - 2024. All rights reserved.